public void SendToInstance <T>(T objectToSend, HYPInstance instance, LoungeMessageType messageType) where T : class { if (instance == null) { return; } bool isList = IsInstanceOfGenericType(typeof(List <>), objectToSend); string serializedObject = JsonConvert.SerializeObject(objectToSend); var message = new LoungeMessage(serializedObject, (int)messageType, isList); string serializedMessage = JsonConvert.SerializeObject(message); NSData data = NSData.FromString(serializedMessage, NSStringEncoding.UTF8); hype.SendData(data, instance); }
public void DecodeReceivedMessage(HYPMessage message) { var loungeMessageString = new NSString(message.Data, NSStringEncoding.UTF8).ToString(); LoungeMessage loungeMessage = JsonConvert.DeserializeObject <LoungeMessage>(loungeMessageString); switch (loungeMessage.LoungeMessageType) { case (int)LoungeMessageType.LoungeDiscovery: if (loungeMessage.IsList) { ReceiveLoungeDiscoveryMessage( JsonConvert.DeserializeObject <List <Lounge> >(loungeMessage.JsonPayload)); } else { ReceiveLoungeDiscoveryMessage( JsonConvert.DeserializeObject <Lounge>(loungeMessage.JsonPayload)); } break; } }