public QTResponsableMessage(QTResponsableMessage sourceMessage = null) { onResponse += debugResponse; if (sourceMessage != null) { responseID = sourceMessage.responseID; } else { responseID = Guid.NewGuid().ToString(); } }
public void sendMessage(QTMessage message) { lock (sendLock) { try { if (client.Connected == false) { return; } byte[] bytes = QTUtils.MessageToByteArray(message); byte[] sizeBytes = BitConverter.GetBytes(bytes.Length); try { debugSent(sizeBytes, bytes); thread.stream.Write(sizeBytes, 0, sizeBytes.Length); thread.stream.Write(bytes, 0, bytes.Length); } catch (Exception e) { QTDebugger.instance.debugWarning(QTDebugger.debugType.NETWORK, "[" + type + "_base] Error while writing the NetworkStream-"); QTDebugger.instance.debugError(QTDebugger.debugType.NETWORK, e); closeConnection(); } var responsableValid = message as QTResponsableMessage; if (responsableValid != null) { QTResponsableMessage responseMessage = (QTResponsableMessage)message; awaitingResponse.Add(responseMessage.responseID, responseMessage); } onMessageSent(message); } catch (Exception e) { Debug.LogWarning(e); } } }
public void processQueue() { lock (recieveLock) { try { if (queuedMessages.Count < 1) { return; } List <QTMessage> queue = queuedMessages.ToList(); foreach (QTMessage message in queue) { try { onMessageRecieved(message); var responsableValid = message as QTResponsableMessage; if (responsableValid != null) { QTResponsableMessage responseMessage = (QTResponsableMessage)message; if (awaitingResponse.ContainsKey(responseMessage.responseID)) { awaitingResponse[responseMessage.responseID].onResponse(responseMessage); awaitingResponse.Remove(responseMessage.responseID); } } } catch (Exception e) { Debug.LogError(e); } queuedMessages.Remove(message); } } catch (Exception e) { Debug.LogWarning(e); } } }
public LoginReplyMessage(QTResponsableMessage _message = null) : base(_message) { messageType = type.LOGIN_REPLY; }
public RoomsMessage(QTResponsableMessage _message = null) : base(_message) { messageType = type.ROOMS; }
public InstanceMessage(QTResponsableMessage _message = null) : base(_message) { messageType = type.INSTANCE; }
public RegisterReplyMessage(QTResponsableMessage _message = null) : base(_message) { messageType = type.REGISTER_REPLY; }
public void debugResponse(QTResponsableMessage message) { QTDebugger.instance.debug(QTDebugger.debugType.NETWORK, "Got response for message with ID - " + message.responseID); }
public HeartbeatMessage(QTResponsableMessage _message = null) : base(_message) { messageType = type.HEARTBEAT; }