public static T GetMulticastMessage <T> (FunMulticastMessage msg, MulticastMessageType msg_type) { try { object _msg = null; Extensible.TryGetValue(serializer_, MessageTable.GetType(msg_type), msg, (int)msg_type, DataFormat.Default, true, out _msg); FunDebug.Assert(_msg != null, "TryGetValue() failed. Please check the message type."); return((T)_msg); } catch (Exception e) { Type type = MessageTable.GetType(msg_type); FunDebug.LogError("FunapiMessage.GetMulticastMessage - Failed to decode '{0}' ({1})\n{2}", type, msg_type, e.ToString()); if (ParsingErrorCallback != null) { ParsingErrorCallback(type); } } return(default(T)); }
// For Multicast messages public static FunMulticastMessage CreateMulticastMessage(object msg, MulticastMessageType msg_type) { if (msg is Enum) { msg = (Int32)msg; } try { FunMulticastMessage _msg = new FunMulticastMessage(); Extensible.AppendValue(serializer_, _msg, (int)msg_type, DataFormat.Default, msg); return(_msg); } catch (Exception e) { Type type = MessageTable.GetType(msg_type); FunDebug.LogError("FunapiMessage.CreateMulticastMessage - Failed to create '{0}' ({1})\n{2}", type, msg_type, e.ToString()); if (ParsingErrorCallback != null) { ParsingErrorCallback(type); } } return(null); }
// For Multicast messages public static FunMulticastMessage CreateFunMessage(object msg, MulticastMessageType msg_type) { if (msg is Enum) { msg = (Int32)msg; } FunMulticastMessage _msg = new FunMulticastMessage(); Extensible.AppendValue(serializer_, _msg, (int)msg_type, DataFormat.Default, msg); return(_msg); }
public static object GetMessage(FunMulticastMessage msg, MulticastMessageType 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) { FunDebug.Log("Failed to decode {0} {1}", MessageTable.GetType(msg_type), (int)msg_type); return(null); } return(_msg); }
public static object GetMulticastMessage(FunMulticastMessage msg, MulticastMessageType msg_type) { return(GetMulticastMessage <object>(msg, msg_type)); }