Exemplo n.º 1
0
        public static ModPacket GetPacketTo(INetHandler target, Mod mod)
        {
            int id;

            if (!handlersInverse.TryGetValue(target, out id))
            {
                throw new ArgumentException();
            }

            ModPacket packet = mod.GetPacket();

            if (prefix != 0)
            {
                packet.Write(prefix);
            }

            if (bigIds)
            {
                packet.Write((UInt16)id);
            }
            else
            {
                packet.Write((byte)id);
            }

            return(packet);
        }
Exemplo n.º 2
0
        public static void AddHandler(INetHandler handler)
        {
            if (inited)
            {
                throw new InvalidOperationException();
            }

            loadList.Add(handler);
        }
Exemplo n.º 3
0
 internal NetClient(INetHandler netHandler)
 {
     if (netHandler == null)
     {
         throw new JKClientException(new ArgumentNullException(nameof(netHandler)));
     }
     this.net            = new NetSystem();
     this.NetHandler     = netHandler;
     this.packetReceived = new byte[this.NetHandler.MaxMessageLength];
 }
Exemplo n.º 4
0
    public static void DispatchResponse(INetHandler NetHandler, byte[] Buffer, int Size)
    {
        ushort ResponseID = BitConverter.ToUInt16(Buffer, 0);

        switch ((ERecvMsgType)ResponseID)
        {
        case ERecvMsgType.T_TURN: NetHandler.Message(new CRecvMsgTurn(Buffer)); return;

        case ERecvMsgType.T_WELCOME: NetHandler.Message(new CRecvMsgWelcome(Buffer)); return;

        default:
            Debug.LogError("Network Response " + ResponseID + " unknown");
            return;
        }
        ;
    }
Exemplo n.º 5
0
 public CNet()
 {
     // TODO: The net class needs a way to interact with GameSession or something?
     _netHandler = null;
 }
Exemplo n.º 6
0
 //---------------------------------------
 public UDPClient(INetHandler handler)
 {
     m_Handler = handler;
 }
Exemplo n.º 7
0
 public TCPClient(INetHandler cmd)
 {
     m_Handler = cmd;
 }
Exemplo n.º 8
0
 public TcpNetChannel(INetHandler handler)
 {
     this._handler = handler;
     this._handler.OnEventRaised += _handler_OnMessageRaised;
     this.ct = tokenSource.Token;
 }
Exemplo n.º 9
0
 public TCPClient(INetHandler handle)
 {
     _mHandler = handle;
 }