void onMulticastChannelReceived(string channel_id, string sender, object body) { if (multicast_.encoding == FunEncoding.kJson) { string channel = FunapiMessage.JsonHelper.GetStringField(body, "_channel"); FunDebug.Assert(channel != null && channel == channel_id); string message = FunapiMessage.JsonHelper.GetStringField(body, "_message"); FunDebug.Log("Received a multicast message from the '{0}' channel.\nMessage: {1}", channel_id, message); } else { FunDebug.Assert(body is FunMulticastMessage); FunMulticastMessage mcast_msg = body as FunMulticastMessage; FunDebug.Assert(channel_id == mcast_msg.channel); object obj = FunapiMessage.GetMessage(mcast_msg, MulticastMessageType.pbuf_hello); PbufHelloMessage hello_msg = obj as PbufHelloMessage; if (hello_msg == null) { return; } FunDebug.Log("Received a multicast message from the '{0}' channel.\nMessage: {1}", channel_id, hello_msg.message); } }
private void onMessageReceived(string msg_type, object message) { MessageType msgType; if (!!!Enum.TryParse(msg_type, out msgType)) { Debug.LogWarning("Unregistered msg type - " + msg_type); return; } var msg = FunapiMessage.GetMessage( message as funapi.network.fun_message.FunMessage, msgType); if (msg == null) { Debug.LogError("Cannot parse msg - " + msg + "as " + msgType); return; } #if DEBUG Debug.LogFormat("[MsgDump] <color=blue>{0}</color> : {1}", msg_type, MiniJSON.Json.Serialize(msg)); #endif base.notifyServerMessage(msgType, msg); }
void onReceivedMessage(string type, object message) { if (type == "echo" || type == "pbuf_echo") { --sending_count_; if (sending_count_ <= 0) { is_done_ = true; } } if (type == "echo") { Dictionary <string, object> json = message as Dictionary <string, object>; FunDebug.Log("[{0}] received: {1} (left:{2})", client_id_, json["message"] as string, sending_count_); } else if (type == "pbuf_echo") { FunMessage msg = message as FunMessage; object obj = FunapiMessage.GetMessage(msg, MessageType.pbuf_echo); if (obj == null) { return; } PbufEchoMessage echo = obj as PbufEchoMessage; FunDebug.Log("[{0}] received: {1} (left:{2})", client_id_, echo.msg, sending_count_); } }
void onReceivedMessage(string type, object message) { if (type == "echo") { FunDebug.Assert(message is Dictionary <string, object>); Dictionary <string, object> json = message as Dictionary <string, object>; FunDebug.Log("Received an echo message: {0}", json["message"]); } else if (type == "pbuf_echo") { FunMessage msg = message as FunMessage; PbufEchoMessage echo = FunapiMessage.GetMessage <PbufEchoMessage>(msg, MessageType.pbuf_echo); FunDebug.Log("Received an echo message: {0}", echo.msg); } }
void onEchoWithProtobuf(object message) { FunDebug.Assert(message is FunMessage); FunMessage msg = message as FunMessage; object obj = FunapiMessage.GetMessage(msg, MessageType.pbuf_echo); if (obj == null) { return; } PbufEchoMessage echo = obj as PbufEchoMessage; FunDebug.Log("Received an echo message: {0}", echo.msg); }
void onReceivedMessage(string type, object message) { if (type == "echo") { Dictionary <string, object> json = message as Dictionary <string, object>; FunDebug.Log("[{0}] received: {1}", client_id, json["message"] as string); } else if (type == "pbuf_echo") { FunMessage msg = message as FunMessage; object obj = FunapiMessage.GetMessage(msg, MessageType.pbuf_echo); if (obj == null) { return; } PbufEchoMessage echo = obj as PbufEchoMessage; FunDebug.Log("[{0}] received: {1}", client_id, echo.msg); } }
void onReceivedMessage(string type, object message) { if (type == "echo") { Dictionary <string, object> json = message as Dictionary <string, object>; string echo_msg = json["message"] as string; FunDebug.Log("[{0}:{2}] {1}", id_, echo_msg, ++message_number_); } else if (type == "pbuf_echo") { FunMessage msg = message as FunMessage; object obj = FunapiMessage.GetMessage(msg, MessageType.pbuf_echo); if (obj == null) { return; } PbufEchoMessage echo = obj as PbufEchoMessage; FunDebug.Log("[{0}:{2}] {1}", id_, echo.msg, ++message_number_); } }
void OnReceive(string type, object obj) { FunEncoding encoding = session_.GetEncoding(); string result = ""; if (type == "fb_authentication") { if (encoding == FunEncoding.kJson) { Dictionary <string, object> message = obj as Dictionary <string, object>; result = message["result"].ToString(); } else if (encoding == FunEncoding.kProtobuf) { FunMessage msg = obj as FunMessage; PbufAnotherMessage message = FunapiMessage.GetMessage <PbufAnotherMessage>(msg, MessageType.pbuf_another); result = message.msg; } if (result == "ok") { logged_in_ = true; if (image_ != null && facebook_.MyPicture != null) { image_.texture = facebook_.MyPicture; } setButtonState(true); } else { FunDebug.Log("facebook login authenticatiion failed."); facebook_.Logout(); } } }
void onMaintenanceMessage(object message) { if (encoding_ == FunEncoding.kJson) { JsonAccessor json_helper = FunapiMessage.JsonHelper; FunDebug.Log("Maintenance message\nstart: {0}\nend: {1}\nmessage: {2}", json_helper.GetStringField(message, "date_start"), json_helper.GetStringField(message, "date_end"), json_helper.GetStringField(message, "messages")); } else if (encoding_ == FunEncoding.kProtobuf) { FunMessage msg = message as FunMessage; object obj = FunapiMessage.GetMessage(msg, MessageType.pbuf_maintenance); if (obj == null) { return; } MaintenanceMessage maintenance = obj as MaintenanceMessage; FunDebug.Log("Maintenance message\nstart: {0}\nend: {1}\nmessage: {2}", maintenance.date_start, maintenance.date_end, maintenance.messages); } }