コード例 #1
0
ファイル: HazelTest.cs プロジェクト: Vytek/HazelClient
    private void DataReceived(object sender, DataReceivedEventArgs args)
    {
        connection = (Connection)sender;

        HazelReader reader = new HazelReader(args.Bytes);

        byte header = reader.ReadByte();

        if (DataHandlers.ContainsKey(header))
        {
            UnityMainThreadDispatcher.Instance().Enqueue(() => DataHandlers [header] (connection, reader));
        }
        args.Recycle();
    }
コード例 #2
0
        private static void DataReceivedHandler(object sender, Hazel.DataReceivedEventArgs args)
        {
            Connection  conn   = (Connection)sender;
            HazelReader reader = new HazelReader(args.Bytes);

            byte header = reader.ReadByte();

            if (!userByConnection.ContainsKey(conn) && header > 2)
            {
                return;
            }
            if (userByConnection[conn].name == null && header > 3)
            {
                return;
            }

            if (DataHandlers.ContainsKey(header))
            {
                DataHandlers [header] (conn, reader);
            }

            args.Recycle();
        }