示例#1
0
    public static int OnRecv(byte[] buffer, int length, BaseSocket socket)
    {
        int ret = 0;

        byte commandType=0;

        BASESOCKET_TYPE socketType = socket.SocketType();
                
        switch (socketType)
        {
            case BASESOCKET_TYPE.SOCKET_TCP:               
                {                    
                    ret = CheckPackageLength(buffer, length, out commandType);
                    ////TraceUtil.Log("ServiceManager OnRecv length:" + length + "ret " + ret);
                    if (ret > length)
                    {
                        return ret;
                    }
                }
                break;

            case BASESOCKET_TYPE.SOCKET_UDP:
                ret = length;
                break;

            default:
                break;
        }

        if (ServiceMap.ContainsKey(commandType))
        {
            //TraceUtil.Log("Data Length:" + length + "  CheckLength:" + ret + " BuffLength:" + buffer.Length);
            //TraceUtil.Log("ReceiveTCP:" + commandType + "," + (byte)MasterMsgType.NET_ROOT_TRADE);
            ServiceMap[commandType].SaveResponseHandleToInvoke(buffer.Take(ret).ToArray(), socket.GetSocketId(), commandType);
        }
        else
        {
            //TraceUtil.Log("Data Length:" + length + "  CheckLength:" + ret + " BuffLength:" + buffer.Length);
        }

        return ret;
    }