daltoniam / Starscream

Websockets in swift for iOS and OSX
Apache License 2.0
8.3k stars 1.2k forks source link

Subscribe to rooms #279

Closed dizialina closed 7 years ago

dizialina commented 7 years ago

Hi! I have server with rooms to chat. Full url is ws://93.171.XXX.XX:8080/conversation_realtime/sportspace581a1541590b21.14581077".
But I have to connect to this by 2 steps: 1) connect to "ws://93.171.XXX.XX:8080"
2) subscribe to room "conversation_realtime/sportspace581a1541590b21.14581077"

In JS it looks like:

var _WS_URI = "ws://93.171.242.80:8080";
var webSocket = WS.connect(_WS_URI);

webSocket.on("socket/connect", function(session){
session.subscribe("conversation_realtime/sportspace581a1541590b21.14581077", function(uri, payload){
                    console.log(payload.message.text);
}
}

How can I realize it in swift in Starscream library? Can't find subscribing to rooms.

acmacalister commented 7 years ago

Starscream is WebSocket library providing the base RFC 6455. The Javascript library you are referencing is probably something like Socket.io, OpenTok.js, etc. that is built on top of WebSocket and has the concept of "rooms". You could use this library to build around whatever technology you are using on the JS side or see if there is an existing library for that. Starscream just does merely WebSockets which do not have rooms, namespaces or such.