Using the client manager plugin – Marc Boegem
Marc Boegem explains all the things you can do with the Client Manager plugin
Client Manager Plugin
- Provides information and tools to manage connected clients in Servoy.
- Displays key information such as client ID, application type, open solution name, login date and time, idle time, last access time, host address, host identifier, host name, username, and connection status.
- Allows adding custom information to client information, such as tenant ID or other relevant data.
- Retrieves database logs to identify users locking records and causing issues.
- Enables sending messages to specific clients and shutting down client sessions.
Broadcaster Plugin
- Facilitates communication between different client sessions in NG.
- Allows sending messages, passing information, and opening external windows.
- External windows can be used to display specific parts of the application in a separate window.
- Works with the NG desktop client, providing additional features like focus management and opening external windows in the NG desktop application.
- Some features related to external windows have been removed in recent versions of the NG desktop client, but alternative methods can achieve similar functionality.
External Window Setup
- Involves generating a random channel name, building a URL to open the external window, and passing the channel name as a query string.
- Initializes the broadcaster object in the new session and retrieves channel information using the
clientInformation
call.
- Sets up the broadcaster callback function to accept a payload, which is then parsed into an object.
- Checks the action and updates menu settings in the main window to ensure only one menu is active across all NG Desktop windows.
- Monitors the external calendar channel for liveness by examining the status line of the connected client.
- Cleans up the channel name, destroys the broadcaster, and shuts down the client if the websocket is disconnected.
Sending Messages
- Involves finding the connected client, initiating a broadcaster, broadcasting the message, and destroying the broadcaster.
User Registration
- Handled through code and does not require any user action.
Customization
- Look and feel of messages can be customized using CSS.
Client Manager Session
- The speaker discussed a client manager session with Patrick.
- Patrick mentioned that the previous user manager should not be used anymore.
- The client manager can get a connected client with a filter string.
- The speaker uses additional information, such as the calendar with the channel name, to check for a specific connected client.
- The speaker can only get one connected client back and perform logic on that client.
- The speaker learned about the “no debug” option to start a second client during the demo.
So, I want to do a session on using the client manager plugin. It’s not all that spectacular, I think. The idea for this session came from an actual use case I had with the customer. So, anyone used the client manager plugin? A lot of people, so probably a lot of what I’m going to tell is not even new to you, or maybe you this. Another question, who’s using the user manager plugin? It’s only one. Well, there is a message from the user manager master here, and he contacted me earlier this week saying, you live a client manager session. So, please. So, actually, for people who don’t know, Patrick is also nowadays one of the several employees in the user manager plugin back in the days. It’s been around for quite a while. But it seems that some of the API staff is probably going to break anytime soon. Also, in the new versions of the server, you need additional information on the plugin package, otherwise it won’t run. And Patrick is definitely not going to change that. Luckily, I see there’s a lot of people not using it. So, the client manager plugin, what is it? It is as the name is starting you. It’s about managing your clients, giving you information to, giving you the tools to do that. So, it’s getting information about the connected clients. You can get database works that is quite helpful. You can send messages to your clients, shut down your clients, actually broadcast information. That last bit is where we will be going. We will show you some things. So, if you want to get the client information, you get the JSCline info object. And you can do that for the current session. And then you have, when you ask for the connected clients on the server, you can get that object for each of your clients. So, you can just easily look through that. So, what is in that client information? There is the client ID, which is the UUID. It’s as it’s registered on the application server by server. The application type, so what is the, is it an ng client, have the client? That those are integers and support by the application types in a narrator in server way. It will give you the open solution name. It can give you the open solution name. Then there’s information about the data time of the logging, either any idle time, last access time. That is simply a JavaScript data check that is returned. Then information about the host address, which is the external I think of the connected client host identifier, which is the server name and local IP. The host name, which is the URL you’re connected to, which is good. For example, for the server cloud, that will be admin.servercloud.edu. And then there is the user name, and you are, this is the information which you pass when you do security logging. So, if you, if you register, you use this by email address, the user name will actually be that user email address. And any UUID, which could be the internal UUID of your, of your, of user table or anything else. If that matters to you. And very helpful information is, was the connection status. So, if you have seen the server admin page, you probably see that. If a client is connected, you see that web sockets are connected, but when they close a browser, it will say web sockets are disconnected, and it’s some, some time, don’t get to all even completely kill that session and it’s gone also from your admin page. And then there’s, of course, the get client in those, which could be very helpful to you. There’s some deviled information about the user agent, the platform you’re using local, local is using session piece. And then you can add custom information to that. That has been around for, for a long time. You could do that in smart client already. You could just add information, whatever you like. For example, the, the tenant ID that that particular user is, is part of, well, anything you like. And through the client manager, looking, you can get that client information. You can retrieve that client information and do some nice things with that. Well, I think most of this sounds pretty familiar in the it’s because basically all the client manager is covering with these functions is what is currently available on the server admin page. So it’s the, the solution name. You can get the total number of clients for the particular solution if you, if you summarize the information you get from the connected clients. The application should have the client with the user name, the host name. You external like the user, or anything. And then down here, this is the additional information you, you will, you will get with the user agent platform and local session and any, any of the information you add to that. So the additional information is actually an array he get back. It’s a, a position for each, each bit of information in here. And you can easily write a function that will change, it will convert this into, into an object. So that is, you can, you can just ask for what is the user agent or, or support form or anything, any bit of information that you’re adding yourself. So, I’m looking at database logs, there are a couple of functions that you can, can use database logs can prefer and other users from, from editing records. It’s nice to see which, which other user is actually the, the, the corporate here and is locking that. Basically, if this happens a lot of times you’re just using database transactions the wrong way. But in, in case you encounter this, you can get all the logs through the plugins client manager catalogs. That will give you a data set with all of the information. So that’s the client ID, which data source it is the primary key that’s affected. And then from that information, you get from the data set, you can use the client manager, get the lock by client to get the actual client information object. And as soon as you have the client information object, you can, get the client ID, you can actually message that particular user saying, hey, you’re, you’re locking, you’re locking something. Finish whatever you’re doing close, close your session in a, in a, in a correct way. And then of course, if the user doesn’t respond and you know, he’s not around or whatever. And the documentation is telling you this, but you can, you can call the release logs function, but you have to be careful with it. Because if someone’s actually in a valid transaction, you will just break things. So don’t forget to read, to read the documentation on this and don’t ignore the warning on that. So, yeah, message and shut down. This is similar stuff as that you can do from the, from the admin page, but I, well, there are, will for, for, for applications, not everyone has access to the server admin page and you don’t want the kistan that privilege. So you can actually build similar functions into your application. Okay, I want to shut down one of the, one of the clients that before I do that, I will send them a message. So it’s, it works, works exactly the way as, as from the admin page, the result will be the same thing. I mean, shut down, well, I don’t think there’s any other way of explaining what it is that will just shut you down. And the message will be the, the alert, the alert dialog from the browser. So the, the, this can, this can differ from, from browser to browser, how this will look. So far is a bit more sophisticated and it’s in, or is it in grow them all the other way around. But anyway, this, it depends on the browser, how that will look. It’s not, it’s not all that attractive sometimes. So now we’re, we’re getting to the, the target of this session actually, that is broadcast information, because that sounds, that sounds very attractive. You can, you can do stuff that you fully, what was, what weren’t thinking of. So, what, what does the broadcast information do? It is, it’s actually you subscribe to a broadcast channel. So, but you can, you can make up that channel name yourself, you can generate a new ID for that if you want. So each client that wants to get this broadcast information needs to subscribe to, to the channel with the, with the ID. Or the name actually. The subscription is based on the channel name. The subscription has to have a callback method. So when a particular client receives a block, a bit of the, the, the broadcast information can actually do something with it. Otherwise it’s not really helpful. And each client can has his own identifying name. And that can be helpful. So, for example, the callback, the callback function will also get that particular broadcast name. So you don’t need, if you, if you have like a couple of broadcast channels, you don’t have to program a different callback function for each, for each type of broadcast. So you can just group that and split it by name and you, you see a bit of code later on. So the use cases and there’s probably a lot more that you can think of, but it could be as simple as just messaging another client through dialogue. I must say this, this can be a, yeah, you need to think out this works because the callback function needs to run on the actual client. So if a client is busy for a while, then the callback function will not be called, but will not be executed before that. User chat is actually done. So that means the dollar can be, can be presented a little bit later. The other thing is you can also pass information from one client to another, which is exactly what a normal message would do, but you can, you can think of this a bit wider and you can use a JSON string to pass. And a JSON string is really helpful because it can contain a lot of information that you can pass back and actually do something with it. Well, that is that both of these things I’m going to show you. So I’ve made a little demo application, I hope it’s going to be readable for everyone probably. I don’t know if I. Oh, no, I will just zoom in. It is not as beautiful as Ficros demo solution. I actually work with the, without a database here. So everything you see is just screens, screens in code. Well, here I can, I just made a quick login screen and I can login, for example, or with itself, we can go on. Yeah, it’s easy. I knew his password. So, and actually I can, I can open another window here. And so that’s still. And I can buy it coins and then I know high-yow screen entry as well. So now I’ve got two sessions. The left hand side is Roberts session and the right hand side is higher session. So now when I want to send higher a message here, I can easily use his username that he is a user. And I’ll say, oh, I owe and double pop up in the other dialogue. So, thank you. Is magic. You will be pleased to hear that this is also cross application service of people using the new multiple application service that just broadcast over a bit of revenue queue as well. As I was saying, this is a little bit of a joke this way, although what I told you earlier about the browser dialogues that are not so attractive, these dialogues are a lot more attractive, but as the downside that it has to go through a callback function which can be triggered later. So, what else started this was actually a question from one of my customers and a bit of information I saw on the forum, it was posted by Joanne. So, what if you’re on set, you can do it that way. It must be possible. And it’s valid and Joanne’s not going to tell me, you can’t do it that way. You’re doing it wrong. So, my customer is coming from smart blind, and it means it’s all been converted to NG. But in smart blind, we have this beautiful possibility to open up a second window and have part of your solution being displayed in that separate window, which is permanently on a second one or for example. That can be really helpful when you talk about, for example, a calendar, people at a reception desk do want that whole schedule the whole day. But in the meantime, they have to work in the application. And rather than moving to the calendar and back to what they were doing, it is helpful to have two windows. In NG, this is no longer possible because it’s only a browser window. You can have a phone and dial up here. And that is about it, but that’s forming dial-on.com, move out of your browser window. So, I thought, well, maybe I can make this work with the broadcast plugin. So, what I tried to do, this is the application. I have my home screen here. I have a client, a client, a form, a project form. This is just to illustrate some of the things and I have a calendar here. So, nothing really fancy. When I click this button, I can actually get that calendar externally. And by pressing the button, my main window is gone back to the home screen and people can just go in here, click through the application. And then, it’s like, come to the calendar, it does nothing anymore. So, because it knows you have an external session. From the external session, all normally you can have appointments with the appointment. You have information about a particular client, the project, he’s part of. And it might be that he opened up an appointment in this external calendar window. And then say, wait, but I want to go to that particular client. So, when I’m to illustrate, I just made two dumb buttons here. And when I click that button, my main window goes to the clients, the clients window and the same for the projects. And of course, I owe the alerts, I’ll tell you that. This is a review based on adjacent object. So, it’s not that object is, is carrying, at the information about what you want to do, the action. But also, what client ID is this all about? So, this case, you can work with two windows. So, now the question is, what happens if users just, plus this window again? Well, here you, all of the other stuff that I covered on the client manager plugging, hits, hits in, it kicks in. If I now click the calendar, it will look for that particular session, doesn’t find it anymore. And will display the calendar in your main window again. And now I can do the same thing. I’ll open, open up and show it again. So, these are two separate sessions. These are two separate sessions, meaning also two licenses. Yes. So, that’s important to know before you start doubling the amount of license that you give away. So, but I mean, sometimes the pain of a license is, or the, I’m going to say, the benefits of the second window are, have priority over the pain of an extra license. And actually, it is good to know that you can have these two windows cooperate. And not just being side by side on a window and basically have to separate applications running with one, one launched in the calendar state. And of course, if you think about word load out on the server, if you only open up part of your solution like only the calendar part here, that impact on performance of the total server is far less than running a full, the full application as a separate session. So, that can all be here. Be part of the consideration of doing it this way. Then of course, and yesterday when I was, I was actually preparing my demo solution, I noticed that something has been broken in, or at least was removed from the any desktop client. Because in any desktop client and in all the versions, I was much nicer. I have this used my own credentials. It’s fine. So, this is the end-to-test of her client, which is electron in all the versions when I asked for an external window, that was actually an extra, another end-to-test window that was opened with this, the separate session. So, nothing changes from what I’ve said earlier. To make it work for this demo, I just decided to open it in a browser here. But what is more important, when you use the energy desktop, you actually got other things that can help you. So, if my, if my, any desktop window is really hidden away behind all different applications, then I click the show clients here, then I actually get focus on the energy desktop again. So, it tracks the, what, yeah, the guess the attention of the user. So, that was basically what I want to tell you about the use with the energy desktop, but I was always saying something has been removed from the recent versions. Sorry. I had different, just two different calls. You can’t do the same thing. Okay. You need to do, I think in the desktop details show you about. The other two things, because customers were complaining, is a click on that, I expect to go to the browser. Okay, so you’ll once, you’ll once said, I’ll throw, I’m doing it wrong. I think he had a lot of discussions. I think even the latest final program have already fixed the calendar area. I will show you later because what you’re saying I was hoping to get and I’ve played around with that, but it didn’t give me a satisfying net. I think he was a new MP desktop. But default we now go to our fact. Okay, but I want to say as it should be possible still to win as an MP desktop. I mean my demo stays the same. If you interact with from one window to the other one, you get focus on the MP desktop and that can be done with the desktop one. If you just have a browser based solution or a real browser then, yeah, unfortunately. So I can give you a little bit of information about how it is actually done in code because after all we’ll say again. And we used to actually see some code. I have to look up where I will zoom in a little bit. I realize it’s. Okay, so. Here I have I have my. Session session scope, which really carries all of the year basically all of the the broadcast or information. Then I’m starting this external window from. Sorry from. Here. So what happens when I. What happens when I press the button. I navigate to my home. I navigate to my home screen again. That’s not so interesting. I generate a. Chen. Okay. Yeah. Random. So I’m going to. Channel name. And then I start building the URL to open the external window, which in this case is the server URL, the solution. The actual channel, which are passing as the server channel name, which are passing as a query string. And when we’re in the developer I use this no debug is true, which enables you to actually run multiple browser windows. And then you can actually run. And then you can actually run. And then you can actually run multiple up to whatever your license allows you to do. So, or, or this is to determine how big my screen one. One my screen to be if it’s an just or I showed the external URL, which are. And now I do it on purpose. Yeah. Because the other because the other stuff didn’t work. Not. And otherwise I just use the show URL. So that is not not. This is not too. To excite the most important part here is. Getting that channel name and passing that to the to the new session. So when I get into when I get to the new session. There is this on solution open to. Calendar that will actually see if there’s a channel information. If there’s channel information, I will initialize the broadcast. The broadcast on the second window. And what I also do is I do I make a I make this call. At client information, which again is. Calendar with the channel. How you do it. And it’s not it’s not really that important. There are multiple ways to do this. But I find I find it convenient to have this information. I will show you. Why. So what does the broadcast to do so if you if you for example you. You know quickly. Tell you. Show you how you set up the broadcast and get you done up so I have a scope variable called broadcast that here. That will get the broadcast or checked which I set up here. So this is this is the actual name. Of the. Channel. Sorry no the identifier of the channel. This is the channel name and this is the callback function. This is where the magic actually happens. So when during that callback function you get a name. And in this case I build my broadcast the callback function to accept. Payload payload will be that Jason. So if either of those two don’t exist then we turn here. And if this is the external calendar broadcaster which I can determine by name. Then I will try to actually pass the. Jason string back to an object. And finally if that succeeded then I can I can actually look at the. Look at the content of the the payload so as I was saying I have the action here. So if the action is focused actually that that that already happened because. because all always when you when you make that call either way. So into the main window or the external calendar window in this case. Even send you desktop I do that focus. There with the at least with the all the version of energy desktop or there was some a feature where we set up a custom menu in energy desktop and I know this that when creating the second window that all these menu settings were over written. And what I had to do when as soon as I started the second window I needed to make that call to the main window again to set up the menu. Otherwise it was only wrong window. So you can only that at least was my experience you can only have one menu working on one of the energy desktop windows. And then of course that to the the two examples I did open a project which sets the the selected item of my menu to projects and the other one is is clients. So that is basically it. You want to go down. Yeah. This is the most interesting part for you. Yeah, I was already wondering if you were a desktop or connect. Yeah, but don’t don’t don’t move on to so fast. Because I will cover that. So I showed you when I was collecting the calendar button in the main window that it wouldn’t do anything if the external window was open. So that is all all handled in the call back of that site map component where I check if the external calendar is still alive. So what is important here is at least I need to have that external calendar channel set up in the main window. If that doesn’t exist I can’t even I can’t even have a second second window. And then I get to the point why I wanted to do that to add additional information here. So you you remember here as a calendar with the channel name I can filter all my connected clients or only on that bit of information. So in theory this or in theory in always they should only give me one an array of one connected client. So that is why I don’t have to loop over home my clients because there’s only going to be one one position here. That has the client information from the client information I can read the status line as you hopefully remember that contains information about the web socket. And as long as the web socket is connected that window is still alive. If it is disconnected and that is immediately if I close the browser window with the external calendar the status line will say web socket disconnected. This is going to work so then the whole function returns false. It returns false then of course in the main window I want to clean up my channel name. If there’s a broadcast I want to destroy that broadcast set the broadcast very well to to nil again. And even if I still get a client ID which means that the client still exists then I also want to shut down that client completely. It was the web socket disconnected I know for sure that this window is never going to come back again because it was initiated by the user and if it’s abandoned it’s abandoned. So I think that covers like everything. I’ve seen yeah there’s there’s I can move down a little bit but it seems a bit off here. Hopefully you can still read that. Well, I’m going to send the message to dialogue. This is what actually happens. Again I look for the connective clients I look through the clients I try to get the username that I entered in the username box. And if that web socket is still connected that is the session I want to I want to be on so that is set into the just finding variable and if that exists. I can I can actually. Oh yeah that forgot to tell you each by in order to do it on the solution open. I always register a broadcast or so there’s always going to be a broadcast with the username the channel name and the callback to this function that we were sort of go back to the function that actually shows the dialogue here. So when I when I retrieve that client information I get the username I initiate the broadcast the I broadcast the message and because that’s only one one time thing I immediately destroy the broadcast again. And after all if it couldn’t find the client information that user is probably not online or using the application anymore close to browser or whatever. So it will give you message chain what users not online anymore. Hopefully that all made sense and if you have any questions then I think this is mode. You mentioned that users have to register. Yeah that is that is actually this so that is this. This call when you through the apply manager you call this function get broadcaster which gives you the broadcast to watch act. This is the user name of the in this case username but in the in the. Example of the external calendar I just named that external calendar can be anything the actual channel name which you sent your message to and then the call back message. So this is all you have to do for registering. Do you have to register to use the user. Does the user have to register to use the. No, no, no registering is purely a code code thing you have to you have to execute that bit of code in order to get a session register to it is not something a user actually has to do that’s taken care of by you through code. And the look and feel of the message in your changer. From the dialogues that I showed yeah these are just the dialogues from from server within server so. C is S. Do you do your magic. Yeah, welcome. Other questions. Was it all clear or. What about what about Patrick’s first initial yet. What about it. About the user man. The user man is you play. Yeah, that’s that’s the there’s this is the other one. Yeah, it’s the new one. So the the. S. I was doing apply manager session. Uh, Patrick said well that is related to my previous user manager. So and that should be used anymore. Thanks. All right. There’s no more questions than thank you for your attention. Thank you very much. My one one more question. The area. I hope. Oh. Yeah. Trust and additional question. Not related to that where you work early but you can get. the card manager also has the option to get a connected plant with the filter. But yes, I use that. Yes, I use that on the. Uh, on checking if that. Here this is this is what you mean. So when I open when I open the external calendar, I’ve, I put the additional information being the calendar with the channel name into the additional info. I can check it. I think it’s just the name you had there. I’m I make that bit of a bit of additional information unique. So, uh, the, the, the, uh, the reason for that is I only have one, one, uh, connected client packet. I only can get one connected client back and just do the, thank you. Do the logical map. Okay. All right. Thank you very much for who this was new. You could do this. Well, for me too. Yeah, I even didn’t know that the no debug option to start a second client. So I’ve learned. I’ve learned. But that’s the good part of the demo. Yeah. Yeah. We do this to learn stuff. So I have learned stuff. Thank you very much. Thank you.