OptWriteLine() public static method

public static OptWriteLine ( Object obj ) : void
obj Object
return void
Ejemplo n.º 1
0
        public void HandleClientComm(object client)
        {
            tcpClient    = (TcpClient)client;
            clientStream = tcpClient.GetStream();

            // Define an auth server processor per thread

            byte[] message = new byte[2048];
            int    bytesRead;

            Output.WriteLine("Margin client Connected.");


            // Receive TCP auth packets from the connected client.
            while (working)
            {
                bytesRead = 0;

                try{
                    bytesRead = clientStream.Read(message, 0, 2048);
                }
                catch { break; }

                if (bytesRead == 0)
                {
                    Output.OptWriteLine("Margin: 0 Bytes received");
                    break;
                }

                // Parse the received packet data
                try{
                    byte[] packet = new byte[bytesRead];
                    ArrayUtils.copy(message, 0, packet, 0, bytesRead);
                    packetHandler(packet, clientStream);
                }catch (MarginException marEx) {
                    Output.WriteLine(marEx);
                    break;
                }
            }
            working = false;
            Output.WriteLine("Margin thread closing");
            tcpClient.Close();
            clientStream.Close();
        }