示例#1
0
 /// <summary>
 /// The MAC input block includes a sequence number, packet length, and protocol (for TLS 1.0+) to detect
 /// missing, altered, or extra messages.
 /// </summary>
 private static byte[] CreateMACInfoPad(ulong seqNum, byte recordType, EProtocol protocol, int length)
 {
     byte[] pad;
     byte[] seqData = BitConverter.GetBytes(seqNum);
     if (BitConverter.IsLittleEndian)
     {
         Array.Reverse(seqData);
     }
     if (protocol == EProtocol.SSLv30)
     {
         // With SSL3 should not include version information
         pad = new byte[11];
         Buffer.BlockCopy(seqData, 0, pad, 0, 8);
         pad[8]  = (byte)(recordType);
         pad[9]  = (byte)(length >> 8);
         pad[10] = (byte)(length);
     }
     else
     {
         // Normal TLS additional bytes to be used
         pad = new byte[13];
         Buffer.BlockCopy(seqData, 0, pad, 0, 8);
         pad[8]  = (byte)(recordType);
         pad[9]  = (byte)((int)(protocol) >> 8);
         pad[10] = (byte)((int)(protocol));
         pad[11] = (byte)(length >> 8);
         pad[12] = (byte)(length);
     }
     return(pad);
 }
示例#2
0
        private void onClientDataReceived(IAsyncResult asyncResult)
        {
            pipeServer.EndRead(asyncResult);
            if (inBuffer.Length == 0)
            {
                return;
            }

            EProtocol protocol = (EProtocol)inBuffer[0];

            switch (protocol)
            {
            case EProtocol.SetAttach:
                EAttachPoint attachPoint = (EAttachPoint)inBuffer[1];
                int          x           = inBuffer[2];
                int          y           = inBuffer[3];
                LogManager.Instance.Log(String.Format("Client Command: 修改挂点: {0}-{1},{2}", attachPoint.ToString(), x, y));
                break;
            }
            try
            {
                if (pipeServer.IsConnected)
                {
                    pipeServer.Flush();
                    pipeServer.BeginRead(inBuffer, 0, pipeServer.InBufferSize, onClientDataReceived, pipeServer);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public void AllowTraffic(List <string> ports, List <IPAddress> addresses)
        {
            if ((ports == null || ports.Count == 0) && (addresses == null || addresses.Count == 0))
            {
                defaultAction = EAction.Accept;
            }
            else
            {
                ports?.ForEach(port =>
                {
                    EProtocol protocol = EProtocol.TCP;
                    if (port.Contains('/'))
                    {
                        string[] split = port.Split('/');
                        port           = split[0];
                        protocol       = Enum.Parse <EProtocol>(split[1].ToUpper());
                    }
                    FirewallRules.Add(nextPort++, new FirewallRule
                    {
                        action      = EAction.Accept,
                        protocol    = protocol,
                        destination = new PortTarget(UInt16.Parse(port))
                    });
                });

                addresses?.ForEach(address =>
                {
                    FirewallRules.Add(nextPort++, new FirewallRule
                    {
                        action      = EAction.Accept,
                        destination = new IPTarget(address)
                    });
                });
            }
        }
示例#4
0
        public HttpsCmsgHello(PacketReader reader)
        {
            TlsVersion   = (EProtocol)reader.ReadUShort();
            ClientRandom = reader.ReadBytes(32); // first four bytes will be unix time gmt
            byte sessionIdLength = reader.ReadByte();

            if (sessionIdLength == 0)
            {
                SessionID = null;
            }
            else
            {
                SessionID = reader.ReadBytes(sessionIdLength);
            }
            ushort ciphersLength = reader.ReadUShort();

            if (ciphersLength % 2 != 0)
            {
                throw new HttpsException($"unsupported cipher length {ciphersLength}", reader);
            }
            Ciphers = new ECipherSuite[ciphersLength / 2];
            for (int i = 0; i < Ciphers.Length; i++)
            {
                Ciphers[i] = (ECipherSuite)reader.ReadUShort();
            }
            byte compressionsLength = reader.ReadByte();

            Compressions = reader.ReadBytes(compressionsLength);
        }
示例#5
0
 public string GetTimeString(
     EElement pStart       = EElement.eHours,
     EElement pEnd         = EElement.eResidual,
     EMode pTimeMode       = EMode.eDefaultMode,
     EProtocol pTimeFormat = EProtocol.eDefaultProtocol)
 {
     return(GetTimeStringNoOptionalArgs(pStart, pEnd, pTimeMode, pTimeFormat));
 }
示例#6
0
 public Msg(EProtocol p, ETopService ts, int ls, XmlDocument c)
 {
     protocol   = p;
     topService = ts;
     lowService = ls;
     content    = c;
     length     = Encoding.UTF8.GetBytes(c.InnerXml).Length;
 }
示例#7
0
 /// <summary>
 /// Client joined event
 /// </summary>
 /// <param name="userID">User ID</param>
 /// <param name="protocol">Protocol</param>
 private void ClientJoinedEvent(int userID, EProtocol protocol)
 {
     if (Protocol == EProtocol.Unspecified)
     {
         Protocol = protocol;
         SendLogInMessageAsync();
         OnClientJoined?.Invoke(userID, protocol);
     }
 }
示例#8
0
        /// <summary>
        /// Create listener (asynchronous)
        /// </summary>
        /// <param name="protocol">Protocol</param>
        /// <param name="port">Port (if 0, default TetriNET port used)</param>
        /// <param name="maxUsers">Maximal amount of users (if 0, default TetriNET maximum of users is used)</param>
        /// <returns>Server connection task</returns>
        internal static Task <ServerListener> CreateListenerAsync(EProtocol protocol, ushort port, uint maxUsers)
        {
            ushort p                  = ((port > 0) ? port : defaultPort);
            uint   max_users          = ((maxUsers > 0) ? maxUsers : defaultMaxUsers);
            Task <ServerListener> ret = new Task <ServerListener>(() => ServerListener.Create(protocol, p, max_users));

            ret.Start();
            return(ret);
        }
示例#9
0
        /// <summary>
        /// Creates a SSLv3 message authentification code for the passed buffer.
        /// </summary>
        private static byte[] CreateMAC(EProtocol protocol, KeyedHashAlgorithm hasher, ulong seqNum, ERecordType recordType, byte[] buffer, int offset)
        {
            int bufferLengthTransformed = buffer.Length - offset;

            // hash seq_num, fragment type, fragment length
            byte[] infoPad = CreateMACInfoPad(seqNum, (byte)recordType, protocol, bufferLengthTransformed);
            // hash(MAC_write_secret + pad_2 + hash(MAC_write_secret + pad_1 + seq_num + record_type + length + content));
            hasher.Initialize();
            hasher.TransformBlock(infoPad, 0, infoPad.Length, infoPad, 0);
            hasher.TransformFinalBlock(buffer, offset, bufferLengthTransformed);
            return(hasher.Hash);
        }
示例#10
0
 /// <summary>
 /// Client joined event
 /// </summary>
 /// <param name="userID">User ID</param>
 /// <param name="protocol">Protocol</param>
 private void ClientJoinedEvent(int userID, EProtocol protocol)
 {
     if (user == null)
     {
         User user = new User(userID, clientConnection.Username);
         if (users.Insert(user, userID))
         {
             this.user = user;
             OnClientJoined?.Invoke(User);
         }
     }
 }
示例#11
0
 public HttpsReader(HttpsSession session, byte[] buffer, int length)
     : base(buffer, length)
 {
     IsDecrypted   = false;
     Session       = session;
     RecordType    = (ERecordType)ReadByte();
     RecordVersion = (EProtocol)ReadUShort();
     RecordLength  = ReadUShort();
     VerifyLengthRemaining(this, LengthRemaining, "SSL record header");
     if (Session?.IsClientEncrypting ?? false)
     {
         Decrypt();
     }
 }
示例#12
0
文件: CWCF.cs 项目: GJSoftware/Tool
 public static T CreateServiceByUrl <T>(string url, EProtocol bing)
 {
     try
     {
         if (string.IsNullOrEmpty(url))
         {
             throw new NotSupportedException("This url is not Null or Empty!");
         }
         EndpointAddress    address = new EndpointAddress(url);
         Binding            binding = CreateBinding(bing);
         ChannelFactory <T> factory = new ChannelFactory <T>(binding, address);
         return(factory.CreateChannel());
     }
     catch (Exception ex)
     {
         throw new Exception("创建服务工厂出现异常:" + ex.ToString());
     }
 }
示例#13
0
        /// <summary>
        /// Create server listener
        /// </summary>
        /// <param name="protocol">Protocol</param>
        /// <param name="port">Port</param>
        /// <param name="maxUsers">Maximal amount of users</param>
        /// <returns></returns>
        public static ServerListener Create(EProtocol protocol, ushort port, uint maxUsers)
        {
            ServerListener ret          = null;
            TcpListener    tcp_listener = TcpListener.Create(port);

            tcp_listener.Start((int)maxUsers);
            AddressFamily used_address_family = tcp_listener.LocalEndpoint.AddressFamily;

            if (used_address_family == AddressFamily.InterNetwork)
            {
                ret = new ServerListener(protocol, tcp_listener);
            }
            else
            {
                tcp_listener.Stop();
                throw new UnsupportedAddressFamilyException(used_address_family);
            }
            return(ret);
        }
示例#14
0
        /// <summary>
        /// Create server lobby
        /// </summary>
        /// <param name="protocol">Protocol</param>
        /// <param name="port">Port</param>
        /// <param name="maxUsers">Maximal amount of users</param>
        /// <returns>Host lobby task</returns>
        public static Task <IHostLobby> CreateServerLobby(EProtocol protocol, ushort port, uint maxUsers)
        {
            Task <IHostLobby> ret = Task.FromResult <IHostLobby>(null);

            if (protocol != EProtocol.Unspecified)
            {
                ret = new Task <IHostLobby>(() =>
                {
                    ServerLobby server_lobby = null;
                    ushort p       = ((port > 0) ? port : Connector.defaultPort);
                    uint max_users = ((maxUsers > 0) ? maxUsers : Connector.defaultMaxUsers);
                    ServerListener server_listener = Connector.CreateListenerAsync(protocol, p, max_users).GetAwaiter().GetResult();
                    if (server_listener != null)
                    {
                        server_lobby = new ServerLobby(server_listener, max_users);
                    }
                    return(server_lobby);
                });
                ret.Start();
            }
            return(ret);
        }
示例#15
0
 public TestTransport(EProtocol aTxProtocol, EProtocol aRxProtocol, string aLocalAddr, string aRemoteAddr, Logger aLog, ETest aTest)
     : base(aLocalAddr, aLog, aTest)
 {
     if (aRemoteAddr == null)
     {
         iAbortMsg  = "DS device undefined";
         iAbortTest = true;
         return;
     }
     try
     {
         if ((aTxProtocol == EProtocol.eTcp) && (aRxProtocol == EProtocol.eTcp))
         {
             iConx = new TcpConx(aLocalAddr, aRemoteAddr);
         }
         else if ((aTxProtocol == EProtocol.eUdp) && (aRxProtocol == EProtocol.eUdp))
         {
             iConx = new UdpConx(aLocalAddr, aRemoteAddr);
         }
         else if ((aTxProtocol == EProtocol.eUdp) && (aRxProtocol == EProtocol.eUdpMulti))
         {
             iConx = new UdpMultiRespondConx(aLocalAddr, aRemoteAddr);
         }
         else if ((aTxProtocol == EProtocol.eUdpMulti) && (aRxProtocol == EProtocol.eUdp))
         {
             iConx = new UdpMultiSenderConx(aLocalAddr, aRemoteAddr);
         }
         else
         {
             Assert.Check(false, "Invalid test configuration");
         }
     }
     catch (Exception e)
     {
         iAbortMsg  = e.ToString();
         iAbortTest = true;
     }
 }
示例#16
0
文件: CWCF.cs 项目: GJSoftware/Tool
        /// <summary>
        /// 创建传输协议
        /// </summary>
        /// <param name="binding">传输协议名称</param>
        /// <returns></returns>
        private static Binding CreateBinding(EProtocol binding)
        {
            Binding bindinginstance = null;

            if (binding == EProtocol.BasicHttpBinding)
            {
                BasicHttpBinding ws = new BasicHttpBinding();
                ws.MaxBufferSize          = 2147483647;
                ws.MaxBufferPoolSize      = 2147483647;
                ws.MaxReceivedMessageSize = 2147483647;
                ws.ReaderQuotas.MaxStringContentLength = 2147483647;
                ws.CloseTimeout   = new TimeSpan(0, 30, 0);
                ws.OpenTimeout    = new TimeSpan(0, 30, 0);
                ws.ReceiveTimeout = new TimeSpan(0, 30, 0);
                ws.SendTimeout    = new TimeSpan(0, 30, 0);
                ws.Security.Mode  = BasicHttpSecurityMode.None;
                bindinginstance   = ws;
            }
            else if (binding == EProtocol.NetTcpbingding)
            {
                NetTcpBinding ws = new NetTcpBinding();
                ws.MaxReceivedMessageSize = 65535000;
                ws.Security.Mode          = SecurityMode.None;
                bindinginstance           = ws;
            }
            else if (binding == EProtocol.WSHttpBinding)
            {
                WSHttpBinding ws = new WSHttpBinding(SecurityMode.None);
                ws.MaxBufferPoolSize      = 65535000;
                ws.MaxReceivedMessageSize = 65535000;
                ws.TextEncoding           = Encoding.UTF8;
                ws.Security.Message.ClientCredentialType   = System.ServiceModel.MessageCredentialType.Windows;
                ws.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.Windows;
                bindinginstance = ws;
            }
            return(bindinginstance);
        }
示例#17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tcpClient">TCP client</param>
 /// <param name="protocol">Protocol</param>
 internal ServerConnection(TcpClient tcpClient, EProtocol protocol)
 {
     this.tcpClient         = tcpClient;
     messageParser          = new MessageParser(protocol);
     messageBuilder         = new MessageBuilder(protocol);
     tcpClientNetworkStream = tcpClient.GetStream();
     Protocol = protocol;
     messageParser.OnUserTeamNameChanged     += OnUserTeamNameChanged;
     messageParser.OnUserChatMessageReceived += OnUserChatMessageReceived;
     messageParser.OnUserChatActionReceived  += OnUserChatActionReceived;
     messageParser.OnGameChatMessageReceived += OnGameChatMessageReceived;
     messageParser.OnUserLevelUpdate         += OnUserLevelUpdate;
     messageParser.OnClassicModeAddLines     += OnClassicModeAddLines;
     messageParser.OnUserSpecialUsedForAll   += OnUserSpecialUsedForAll;
     messageParser.OnUserSpecialUsed         += OnUserSpecialUsed;
     messageParser.OnUserLost                  += OnUserLost;
     messageParser.OnPauseGame                 += OnPauseGame;
     messageParser.OnResumeGame                += OnResumeGame;
     messageParser.OnUserFullFieldUpdate       += OnUserFullFieldUpdate;
     messageParser.OnUserPartialFieldUpdate    += OnUserPartialFieldUpdate;
     messageParser.OnClientLogIn               += OnClientLogIn;
     messageParser.OnClientInformationReceived += OnClientInformationReceived;
     messageParser.OnStartGame                 += OnStartGame;
     messageParser.OnStopGame                  += OnStopGame;
     listenerThread = new Thread((that) =>
     {
         if (that is ServerConnection)
         {
             ServerConnection server_connection = (ServerConnection)that;
             using (MemoryStream buffer = new MemoryStream())
             {
                 while (server_connection.CanReceive)
                 {
                     lock (server_connection.tcpClient)
                     {
                         int available = server_connection.tcpClient.Available;
                         if (available > 0)
                         {
                             byte[] available_data = new byte[available];
                             if (server_connection.tcpClientNetworkStream.Read(available_data, 0, available) == available)
                             {
                                 foreach (byte b in available_data)
                                 {
                                     if (b == 0xFF)
                                     {
                                         byte[] data = new byte[buffer.Length];
                                         if (buffer.Read(data, 0, data.Length) == data.Length)
                                         {
                                             messageParser.ParseMessage(Encoding.UTF8.GetString(data));
                                         }
                                         buffer.SetLength(0L);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     });
     listenerThread.Start(this);
 }
示例#18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="protocol">Protocol</param>
 /// <param name="tcpListener">TCP listener</param>
 private ServerListener(EProtocol protocol, TcpListener tcpListener)
 {
     Protocol       = protocol;
     TCPListener    = tcpListener;
     listenerThread = new Thread((that) =>
     {
         if (that is ServerListener)
         {
             ServerListener listener = (ServerListener)that;
             while (listener.TCPListener != null)
             {
                 lock (listener.TCPListener)
                 {
                     if (listener.TCPListener.Pending())
                     {
                         TcpClient tcp_client = listener.TCPListener.AcceptTcpClient();
                         if (tcp_client != null)
                         {
                             bool allow     = (Whitelist.Count <= 0);
                             string address = ((IPEndPoint)(tcp_client.Client.RemoteEndPoint)).Address.ToString();
                             if (!allow)
                             {
                                 allow = Whitelist.Contains(address);
                             }
                             if (allow)
                             {
                                 allow = !(Bans.Contains(address));
                             }
                             if (allow)
                             {
                                 ServerConnection server_connection = new ServerConnection(tcp_client, protocol);
                                 lock (listener.serverConnections)
                                 {
                                     listener.serverConnections.Add(server_connection);
                                 }
                                 OnClientConnectionAccepted?.Invoke(server_connection);
                             }
                             else
                             {
                                 OnClientConnectionDenied?.Invoke(tcp_client);
                                 tcp_client.Dispose();
                             }
                         }
                     }
                 }
                 lock (listener.serverConnections)
                 {
                     List <Tuple <int, ServerConnection> > dispose_server_connections = null;
                     for (int i = 0; i < listener.serverConnections.Count; i++)
                     {
                         ServerConnection server_connection = listener.serverConnections[i];
                         if ((!(server_connection.CanReceive)) && (!(server_connection.CanSend)))
                         {
                             if (dispose_server_connections == null)
                             {
                                 dispose_server_connections = new List <Tuple <int, ServerConnection> >();
                             }
                             dispose_server_connections.Add(new Tuple <int, ServerConnection>(i, server_connection));
                         }
                     }
                     dispose_server_connections.Reverse();
                     foreach (Tuple <int, ServerConnection> server_connection in dispose_server_connections)
                     {
                         listener.serverConnections.RemoveAt(server_connection.Item1);
                     }
                 }
                 Thread.Sleep(20);
             }
         }
     });
     listenerThread.Start(this);
 }
示例#19
0
 public static FbxTime FromTimeString(string pTime, EMode pTimeMode = EMode.eDefaultMode, EProtocol pTimeFormat = EProtocol.eDefaultProtocol)
 {
     return(FbxTime.FromTimeStringNoOptionalArgs(pTime, pTimeMode, pTimeFormat));
 }
示例#20
0
        public void process_user_operation(CPacket message)
        {
            EProtocol protocol_id = (EProtocol)message.pop_protocol_id();

            switch (protocol_id)
            {
                #region receive from server

            case EProtocol.CHAT_MSG_ACK:
            {
                string RoomName = message.pop_string();
                string UserName = message.pop_string();
                string Message  = message.pop_string();

                if (!ChatPage_Return_Callback.ContainsKey(RoomName))
                {
                    break;
                }

                ChatPage_Return_Callback[RoomName](EChatItem.Chat, new ChatItem {
                        Name = UserName, Message = Message, SendTime = DateTime.UtcNow
                    });
            }
            break;

            case EProtocol.SET_NAME_ACK:
            {
                if (LoginPage_Return_Callback == null)
                {
                    break;
                }
                LoginPage_Return_Callback((short)protocol_id);
            }
            break;

            case EProtocol.SET_NAME_ERROR_EXISTED:
            {
                if (LoginPage_Return_Callback == null)
                {
                    break;
                }
                LoginPage_Return_Callback((short)protocol_id);
            }
            break;

            case EProtocol.ASK_USER_LIST_ACK:
            {
            }
            break;

            case EProtocol.CREATE_CHAT_ROOM_ACK:
            {
                if (Create_Page_Callback == null)
                {
                    break;
                }
                var UserList      = message.pop_string_list();
                var ServerName    = message.pop_string();
                var ServerInitial = message.pop_string();
                Create_Page_Callback((short)protocol_id, UserList, ServerName, ServerInitial);
            }
            break;

            case EProtocol.CREATE_CHAT_ROOM_ERROR:
            {
                if (Create_Page_Callback == null)
                {
                    break;
                }
                Create_Page_Callback((short)protocol_id, null, null, null);
            }
            break;

            case EProtocol.EXIT_THE_ROOM_USER:
            {
                string RoomName = message.pop_string();
                string UserName = message.pop_string();

                if (!ChatPage_Return_Callback.ContainsKey(RoomName))
                {
                    break;
                }

                ChatPage_Return_Callback[RoomName](EChatItem.UserExit, UserName);
            }
            break;

            case EProtocol.ADD_USER_IN_ROOM_ACK:
            {
            }
            break;

            case EProtocol.JOIN_THE_ROOM_ACK:
            {
                if (Create_Page_Callback == null)
                {
                    break;
                }
                var UserList      = message.pop_string_list();
                var ServerName    = message.pop_string();
                var ServerInitial = message.pop_string();
                Create_Page_Callback((short)protocol_id, UserList, ServerName, ServerInitial);
            }
            break;

            case EProtocol.JOIN_THE_ROOM_ERROR:
            {
                if (Create_Page_Callback == null)
                {
                    break;
                }
                Create_Page_Callback((short)protocol_id, null, null, null);
            }
            break;

            case EProtocol.JOIN_THE_ROOM_NEW_USER:
            {
                string RoomName = message.pop_string();
                string UserName = message.pop_string();

                if (!ChatPage_Return_Callback.ContainsKey(RoomName))
                {
                    break;
                }

                ChatPage_Return_Callback[RoomName](EChatItem.User, new User {
                        Name = UserName
                    });
            }
            break;


                #endregion
            }
        }
示例#21
0
 /// <summary>
 /// Create server lobby
 /// </summary>
 /// <param name="protocol">Protocol</param>
 /// <param name="port">Port</param>
 /// <returns>Lobby task</returns>
 public static Task <IHostLobby> CreateServerLobby(EProtocol protocol, ushort port) => CreateServerLobby(protocol, port, 0U);
示例#22
0
 /// <summary>
 /// Create server lobby
 /// </summary>
 /// <param name="protocol">Protocol</param>
 /// <returns>Lobby task</returns>
 public static Task <IHostLobby> CreateServerLobby(EProtocol protocol) => CreateServerLobby(protocol, 0, 0U);
示例#23
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="protocol">Protocol</param>
 internal MessageBuilder(EProtocol protocol)
 {
     Protocol = protocol;
 }
示例#24
0
 private static extern int socket(EAddressFamily domain, ESocketType socketType, EProtocol protocol);
示例#25
0
 public GameEvent(string tag, EProtocol protocol = EProtocol.Delayed)
 {
     m_Tag      = tag;
     m_Protocol = protocol;
 }
示例#26
0
 public HttpsSession(EProtocol protocol)
 {
     IsClientEncrypting = false;
     IsServerEncrypting = false;
     Protocol           = protocol;
 }
示例#27
0
    private void onSvrDataReceived(IAsyncResult asyncResult)
    {
        // 这里用不到asyncResult
        pipeClient.EndRead(asyncResult);

        EProtocol protocol = (EProtocol)inBuffer[0];

        switch (protocol)
        {
        case EProtocol.PreloadAllSpine:
            Debug.Log("ServerCommand: PreloadSpine");
            int    dirLen = inBuffer[1];
            string dir    = Encoding.UTF8.GetString(inBuffer, 2, dirLen);
            Debug.Log("Preload Dir: " + dir);
            ToolManager.Instance.NeedPreloadSpine = true;
            ToolManager.Instance.SpineDir         = dir;
            break;

        case EProtocol.LoadSpine:
            Debug.Log("ServerCommand: LoadSpine");
            int    nameLen = inBuffer[1];
            string name    = Encoding.UTF8.GetString(inBuffer, 2, nameLen);
            int    zipLen  = inBuffer[2 + nameLen];
            string zipPath = Encoding.UTF8.GetString(inBuffer, 3 + nameLen, zipLen);
            Debug.Log("Name: " + name);
            Debug.Log("Zip: " + zipPath);
            ToolManager.Instance.NeedLoadSpine = true;
            ToolManager.Instance.SpineName     = name;
            ToolManager.Instance.SpineZipPath  = zipPath;
            // ToolManager.Instance.LoadSpine(name, zipPath);
            break;

        case EProtocol.SetAttach:
            print("ServerCommand SetAttach");
            EAttachPoint attachPoint = (EAttachPoint)inBuffer[1];
            int          x           = inBuffer[2];
            int          y           = inBuffer[3];
            ToolManager.Instance.SetAttach(attachPoint, x, y);
            break;

        case EProtocol.PlayAnim:
            print("ServerCommand PlayAnim");
            ToolManager.Instance.NeedPlayAnim = true;
            int    animNameLen = inBuffer[1];
            string animName    = Encoding.UTF8.GetString(inBuffer, 2, animNameLen);
            ToolManager.Instance.AnimName = animName;
            break;
        }

        pipeClient.Flush();

        pipeClient.BeginRead(inBuffer, 0, pipeClient.InBufferSize, onSvrDataReceived, pipeClient);

        //string info = System.Text.Encoding.UTF8.GetString(inBuffer);

        //int len = pipeClient.ReadByte() * 256;
        //len += pipeClient.ReadByte();
        //inBuffer = new byte[len];
        //pipeClient.Read(inBuffer, 0, len);
        //remoteInfo = Encoding.Unicode.GetString(inBuffer);

        // asyncResult.AsyncState
    }