public void Handle(LoginBroadcastResult login_broadcast_result)
        {
            Debug.Log ("login_broadcast_result");
            Debug.Log ( "player_id : " + login_broadcast_result.player_id);

            prefab_manager.InstantiatePlayer (login_broadcast_result.player_id);
        }
Exemple #2
0
    IEnumerator ReadPacket()
    {
        while (true) {
            yield return 0;

            if(stream.DataAvailable == true)
            {
                short size = 0;
                short type = 0;
                byte[] bytes;
                size = reader.ReadInt16 ();
                type = reader.ReadInt16 ();
                Debug.Log ("size : " + size + ", type : " + type);
                bytes = reader.ReadBytes (size);

                if (bytes.Length == size)
                {
                    if (0 <= type && type < PKT_MAX)
                    {
                        MemoryStream memory_stream = new MemoryStream ();
                        memory_stream.Write (bytes, 0, size);
                        memory_stream.Position = 0;

                        switch (type)
                        {
                        case PKT_NONE:
                        {

                        } break;
                        case PKT_SC_LOGIN:
                        {
                            LoginResult login_result = new LoginResult ();
                            login_result = ProtoBuf.Serializer.Deserialize<LoginResult> (memory_stream);
                            LoginResultHandler login_result_handler = new LoginResultHandler ();
                            login_result_handler.Handle (login_result);
                        } break;
                        case PKT_SC_LOGIN_BROADCAST:
                        {
                            LoginBroadcastResult login_broadcast_result = new LoginBroadcastResult ();
                            login_broadcast_result = ProtoBuf.Serializer.Deserialize<LoginBroadcastResult> (memory_stream);
                            LoginBroadcastResultHandler login_broadcast_result_handler = new LoginBroadcastResultHandler ();
                            login_broadcast_result_handler.Handle (login_broadcast_result);
                        } break;
                        case PKT_SC_MOVE_START:
                        {
                            MoveResult move_result = new MoveResult ();
                            move_result = ProtoBuf.Serializer.Deserialize<MoveResult> (memory_stream);
                            MoveResultHandler move_result_handler = new MoveResultHandler ();
                            move_result_handler.Handle (move_result);
                        } break;
                        case PKT_SC_MOVE_STOP:
                        {
                            MoveStopResult move_stop_result = new MoveStopResult ();
                            move_stop_result = ProtoBuf.Serializer.Deserialize<MoveStopResult> (memory_stream);
                            MoveStopResultHandler move_stop_result_handler = new MoveStopResultHandler ();
                            move_stop_result_handler.Handle (move_stop_result);
                        } break;
                        }
                            // Check Packet
                    }
                }
            }
        }
    }