public void AcceptCallback(IAsyncResult ar)
        {
            // Signal the main thread to continue.
            allDone.Set();

            // Get the socket that handles the client request.
            Socket listener = (Socket)ar.AsyncState;
            Socket handler  = listener.EndAccept(ar);

            CommunicationListenerEventArgs args = new CommunicationListenerEventArgs();

            args.Client = new SocketCommunicationClient(handler);
            OnClientAvailable(args);
        }
Esempio n. 2
0
 private void Listener_ClientAvailable(object sender, CommunicationListenerEventArgs e)
 {
     Logger.Log($"Client connected");
     e.Client.Authentificated += (object source, EventArgs args) =>
     {
         ICommunicationClient client = (ICommunicationClient)source;
         Logger.Log($"Client authentificated Type:{client.Type} ID:{client.Id}");
         DeviceClient device = new DeviceClient(client);
         device.ModelAvailable += (object clientS, EventArgs a) =>
         {
             DeviceClient curentClient = (DeviceClient)clientS;
             Logger.Log($"Model data available from client {curentClient.Client.Id}");
             //Console.WriteLine(curentClient.DecodeModel());
             RenderModel(curentClient.DecodeModel());
         };
         devices.Add(device);
         clients.Remove(client);
     };
     clients.Add(e.Client);
 }
 protected virtual void OnClientAvailable(CommunicationListenerEventArgs args)
 {
     ClientAvailable?.Invoke(this, args);
 }