private void OnTransportReceived(IUdpTransport transport, string address, byte[] bytes) { if (bytes.Length <= _maxMessageSize) { var message = _serializer.Deserialize <IMessage>(bytes); switch (message.TypeMessage) { case "authorize": ReceiveAuthorize(address, message); break; case "request": ReceiveRequest(address, message); break; case "response": ReceiveResponse(address, message); break; case "error": ReceiveError(address, message); break; default: Error(address, _invalidMessage); break; } } else { Error(address, _tooBigMessage); } }
public ChatClient(IUdpTransport transport, ProtocolUdpNetwork network, int maxMessageLenght) { _transport = transport; _transport.Disconnected += TransportOnDisconnected; _network = network; _maxMessageLenght = maxMessageLenght; _network.RequestReceived += NetworkOnRequestReceived; _network.Connected += NetworkOnConnected; _network.Start(0); }
public TransportUdpProtocol(IUdpTransport transport, int maxMessageSize, ISerializer serializer) { _transport = transport; _maxMessageSize = maxMessageSize; _serializer = serializer; }
private void OnTransportDisconnected(IUdpTransport transport, string address) { CallDisconnected(address); }
private void TransportOnDisconnected(IUdpTransport transport, string address) { CallChangeStage(ClientStage.Disconnected); CallMessage("Disconnect", true); }