protected void ReconfigureCommunication() { var wasListening = false; if (_communicator != null) { if (_communicator.IsListening) { wasListening = true; Stop(); } _communicator = null; } switch (_communicationType) { case ReceiverTypeEnum.UDP: _communicator = new UdpCommunicator(_port); break; case ReceiverTypeEnum.TCP: throw new NotSupportedException("TCP not yet supported."); default: throw new NotSupportedException("Developer laziness not supported."); } _communicator.PacketReceived += ProcessPacket; if (wasListening) { Start(); } }
private void ProcessPacket(IPacketCommunicator comm, string data) { var js = new JavaScriptSerializer(); var items = js.Deserialize <List <AnyDeltaState> >(data); if (items != null) { StoreDeltaStates(items); } }