コード例 #1
0
        public object GetMessage(FunMessage msg, MessageType msg_type)
        {
            object _msg = null;
            bool success = Extensible.TryGetValue(serializer_, MessageTable.GetType(msg_type), msg,
                                                  (int)msg_type, DataFormat.Default, true, out _msg);
            if (!success)
            {
                DebugUtils.Log("Failed to decode {0} {1}", MessageTable.GetType(msg_type), (int)msg_type);
                return null;
            }

            return _msg;
        }
コード例 #2
0
        private void SendEmptyMessage(TransportProtocol protocol)
        {
            FunapiTransport transport = GetTransport(protocol);
            if (transport == null)
            {
                DebugUtils.Log("SendEmptyMessage - transport is null.");
                return;
            }

            session_protocol_ = protocol;
            DebugUtils.DebugLog("{0} send empty message", transport.str_protocol);

            if (transport.Encoding == FunEncoding.kJson)
            {
                object msg = transport.JsonHelper.Deserialize("{}");
                transport.SendMessage(new FunapiMessage(transport.Protocol, "", msg));
            }
            else if (transport.Encoding == FunEncoding.kProtobuf)
            {
                FunMessage msg = new FunMessage();
                transport.SendMessage(new FunapiMessage(transport.Protocol, "", msg));
            }
        }
コード例 #3
0
 public FunMessage CreateFunMessage(object msg, MessageType msg_type)
 {
     FunMessage _msg = new FunMessage();
     Extensible.AppendValue(serializer_, _msg, (int)msg_type, DataFormat.Default, msg);
     return _msg;
 }
コード例 #4
0
        public object GetMessage(FunMessage msg, Type msg_type, int msg_index)
        {
            object _msg = null;
            bool success = Extensible.TryGetValue(serializer_, msg_type, msg,
                                                  msg_index, DataFormat.Default, true, out _msg);
            if (!success)
            {
                Debug.Log(String.Format("Failed to decode {0} {1}", msg_type, msg_index));
                return null;
            }

            return _msg;
        }
コード例 #5
0
        private void SendAck(FunapiTransport transport, UInt32 ack)
        {
            DebugUtils.Assert(session_reliability_);
            if (transport == null)
            {
                DebugUtils.Log("SendAck - transport is null.");
                return;
            }

            if (state_ == State.kStopped)
                return;

            DebugUtils.DebugLog("{0} send ack message - ack:{1}", transport.Protocol, ack);

            if (transport.Encoding == FunEncoding.kJson)
            {
                object ack_msg = transport.JsonHelper.Deserialize("{}");
                transport.JsonHelper.SetStringField(ack_msg, kSessionIdBodyField, session_id_);
                transport.JsonHelper.SetIntegerField(ack_msg, kAckNumberField, ack);
                transport.SendMessage(new FunapiMessage(transport.Protocol, "", ack_msg));
            }
            else if (transport.Encoding == FunEncoding.kProtobuf)
            {
                FunMessage ack_msg = new FunMessage();
                ack_msg.sid = session_id_;
                ack_msg.ack = ack;
                transport.SendMessage(new FunapiMessage(transport.Protocol, "", ack_msg));
            }
        }
コード例 #6
0
 public static bool TryGetExtension_pbuf_echo(this FunMessage message, out PbufEchoMessage value)
 {
     return(ProtoBuf.Extensible.TryGetValue(message, (int)ExtendedMessageFieldNumber.FunMessage_pbuf_echo, out value));
 }
コード例 #7
0
 public FunMessage CreateFunMessage(object msg, int msg_index)
 {
     FunMessage _msg = new FunMessage();
     Extensible.AppendValue(serializer_, _msg, msg_index, DataFormat.Default, msg);
     return _msg;
 }
コード例 #8
0
 public static void AppendExtension_pbuf_another(this FunMessage message, PbufAnotherMessage value)
 {
     ProtoBuf.Extensible.AppendValue(message, (int)ExtendedMessageFieldNumber.FunMessage_pbuf_another, value);
 }
コード例 #9
0
 public static void AppendExtension_lobby_single_result(this FunMessage message, LobbySingleModeResultMessage value)
 {
     ProtoBuf.Extensible.AppendValue(message, (int)ExtendedMessageFieldNumber.FunMessage_lobby_single_result, value);
 }
コード例 #10
0
 public static bool TryGetExtension_lobby_single_result(this FunMessage message, out LobbySingleModeResultMessage value)
 {
     return(ProtoBuf.Extensible.TryGetValue(message, (int)ExtendedMessageFieldNumber.FunMessage_lobby_single_result, out value));
 }
コード例 #11
0
 public static void AppendExtension_lobby_rank_list_req(this FunMessage message, LobbyRankListRequest value)
 {
     ProtoBuf.Extensible.AppendValue(message, (int)ExtendedMessageFieldNumber.FunMessage_lobby_rank_list_req, value);
 }
コード例 #12
0
 public static bool TryGetExtension_lobby_rank_list_req(this FunMessage message, out LobbyRankListRequest value)
 {
     return(ProtoBuf.Extensible.TryGetValue(message, (int)ExtendedMessageFieldNumber.FunMessage_lobby_rank_list_req, out value));
 }