Is it possible to send events from the server's main form?


Using the chat example as a reference I have managed to set up a client and a server with events. I can send events from the server’s service implementation.

What I would like to be able to do is to have a text edit and a button on my main form. When the user clicks the button on the main form then I want to send a message to a specific client. I’ve tried the code below but I’m guessing that this sends a message to every attached client, correct?

IKioskEventSink lEv = (IKioskEventSink)sinkManager.GetEventSink(Guid.Empty, typeof(IKioskEventSink));
        if (lEv != null)

How do I get the client id of the clients?

In my service I do have a Login and Logout method that creates an object and stores it into a list<> of objects. Is this where I would capture the client id and save it to the newly created object?

public bool Login(string Station)
// provide proper logic to validate the user’s credentials
bool loginValid = !string.IsNullOrEmpty(Station);

        if (loginValid)
            // perform additional setup for the user's session, if needed
            Session["Station"] = Station; // create a session



            catch (Exception ex)

            return true;
            return false;

    public void LogOut()


You need to somehow store your client ID in a separate data structure or you can access all session IDs using SessionManager's method GetAllSessions.

Both approaches have their pros and cons. There is also an universal solution - to implement your own Session Manager.

Let’s assume you have that each client has a Name property and you need to be able to acquire its ClientID based on its name (or Station in your case). The code below assumes that Station is unique.

CustomSessionManager.cs (1.7 KB)


That was exactly what I needed, thank you!

1 Like