private void transmit(String command, Dictionary <String, String> headers, String body) { String outMsg = StompMessage.marshall(command, headers, body); Debug.Log(TAG + ">>> " + outMsg); while (true) { if (outMsg.Length > maxWebSocketFrameSize) { base.Send(outMsg.Substring(0, maxWebSocketFrameSize)); outMsg = outMsg.Substring(maxWebSocketFrameSize); } else { base.Send(outMsg); break; } } }
internal virtual void OnConnected(StompMessage stompMessage) { String username = stompMessage.getHeaders() ["user-name"]; String userId = stompMessage.getHeaders() ["user-id"]; String heartbeat = stompMessage.getHeaders() ["heart-beat"]; if (heartbeat != null) { String[] splittedHeartbeat = heartbeat.Split(','); int? heartbeatPeriod = Int32.Parse(splittedHeartbeat [1]); if (heartbeatPeriod != null && heartbeatPeriod > 0) { ((BacktoryStompWebSocket)this).SetHeartbeatPeriod((double)heartbeatPeriod); } } Debug.Log(TAG + "Web Socket connected to server"); stompConnectionState = StompConnectionState.Connected; eventHandler.OnConnected(username, userId); }
private void onMessage(object sender, MessageEventArgs e) { String messageText = e.Data; Debug.Log(TAG + "<<< " + messageText); StompMessage stompMessage = StompMessage.fromString(messageText); if (stompMessage == null) { return; } if (stompMessage.getCommand().Equals(COMMAND_CONNECTED)) { OnConnected(stompMessage); } else if (stompMessage.getCommand().Equals(COMMAND_MESSAGE)) { eventHandler.OnMessage(stompMessage.getBody()); } else if (stompMessage.getCommand().Equals(COMMAND_RECEIPT)) { String receiptId = stompMessage.getHeaders() ["receipt-id"]; if ("disconnect-ack".Equals(receiptId)) { onDisconnected(); } } else if (stompMessage.getCommand().Equals(COMMAND_ERROR)) { String errorMessage = stompMessage.getHeaders() ["message"]; Debug.LogError(TAG + "Stomp error with message: " + errorMessage); } else { Debug.LogError("Undefined command " + stompMessage.getCommand()); } }
public static String marshall(String command, Dictionary <String, String> headers, String body) { StompMessage frame = new StompMessage(command, headers, body); return(frame.toStringg()); }
internal sealed void OnConnected(StompMessage stompMessage) { base.OnConnected(stompMessage); StartHeartbeatTimer(); }