Example #1
0
        public override void OnRawMessage(string data, Socket handler)
        {
            try
            {
                var parsedMessage = new SocketServer.ParsedMessage(data);
                if (!parsedMessage.message.Contains("UpdatePrinterList"))
                {
                    parsedMessage.message.Contains("InitialConnect");
                }

                var remoteIP = new SocketServer.IPAddressInfo(null, parsedMessage.port);
                if (handler.RemoteEndPoint is IPEndPoint remoteEndPoint)
                {
                    remoteIP.ip = remoteEndPoint.Address;
                }

                ProcessGUIDPortPair(parsedMessage.guid, remoteIP);
                var str = OnClientMessage(parsedMessage.guid, parsedMessage.message);
                if (string.IsNullOrEmpty(str))
                {
                    str = "OK";
                }

                byte[] bytes = Encoding.UTF8.GetBytes(str + "<EOF>");
                handler.Send(bytes);
            }
            catch (ThreadAbortException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                ErrorLogger.LogException("Exception in SocketServer.OnRawMessage " + ex.Message, ex);
            }
        }
Example #2
0
 private void ProcessGUIDPortPair(Guid guid, SocketServer.IPAddressInfo remoteIP)
 {
     lock (client_addresses)
     {
         if (!client_addresses.ContainsKey(guid))
         {
             client_addresses.Add(guid, remoteIP);
             OnNewClientConnection(guid);
         }
         else
         {
             client_addresses[guid] = remoteIP;
         }
     }
 }