예제 #1
0
        private HPSocketCS.HandleResult OnAccept(HPSocketCS.IServer sender, IntPtr connId, IntPtr pClient)
        {
            // 客户进入了
            // 获取客户端ip和端口
            string ip   = string.Empty;
            ushort port = 0;

            if (mServer.GetRemoteAddress(connId, ref ip, ref port) == false)
            {
                return(HPSocketCS.HandleResult.Error);
            }

            CTcpConnect conn;

            lock (this)
            {
                if (mDictConnects.TryGetValue(connId, out conn) == false)
                {
                    conn = new CTcpConnect(this, ip, port, connId);
                    mDictConnects[connId] = conn;
                }
            }

            if (OnTcpConnected != null)
            {
                OnTcpConnected(conn);
            }

            return(HPSocketCS.HandleResult.Ok);
        }
예제 #2
0
        private HPSocketCS.HandleResult OnPointerDataReceive(HPSocketCS.IServer sender, IntPtr connId, IntPtr pData, int length)
        {
            CTcpConnect conn = GetTcpConnect(connId);

            if (conn != null)
            {
                conn.OnDataReceive(pData, length);
            }
            return(HPSocketCS.HandleResult.Ok);
        }
예제 #3
0
 internal void OnRcvPackage(CTcpConnect pClient, byte[] pData, int nLength, Int64 recvTime)
 {
     if (OnReceiveData != null)
     {
         OnReceiveData(pClient, pData, nLength, recvTime);
     }
     else
     {
         RemoteServices.RPCExecuter.Instance.ReceiveData(pClient, pData, nLength, recvTime);
     }
 }
예제 #4
0
        private HPSocketCS.HandleResult OnClose(HPSocketCS.IServer sender, IntPtr connId, HPSocketCS.SocketOperation enOperation, int errorCode)
        {
            CTcpConnect conn = null;

            lock (this)
            {
                mDictConnects.TryRemove(connId, out conn);
                if (conn != null && OnTcpDisConnected != null)
                {
                    OnTcpDisConnected(conn);
                }
            }
            conn.OnDisconnect();
            return(HPSocketCS.HandleResult.Ok);
        }