0

I'm trying to build an iOS app that serves up frames from the camera over a web socket. Starscream seems to be the library of choice for web sockets on iOS. All the Starscream examples I can find (e.g. here or here) start with a line like this one:

socket = WebSocket(url: URL(string: "ws://localhost:8080/")!)

I.e. they assume that we are opening a connection to a server, and after that we can send and receive data over the web socket. What I need is the other way around, I will be serving the data over a web socket and a client will connect to me so that I can send the data over a web socket.

Is that possible in iOS, potentially using Starscream? How?

dumbledad
  • 16,305
  • 23
  • 120
  • 273
  • remember by default apple blocks all non https requests. Target -> Info -> App Transport Security Settings > Allow Arbitrary Loads = YES – Eddwin Paz Nov 06 '18 at 13:34
  • This is more a backend related question than iOS. StarScream indeed is a iOS Library for WebSockets. The way to approach this problem is to build a session for each client. example. Client 1 connects and gets assigned a uniqueID for that session. and he will be listening to that channel waiting for the remote server to send messages on that channel. – Eddwin Paz Nov 06 '18 at 13:37
  • Along with starscream you need socket.io or another non-blocking i/o library to handle the message broadcast to all listening devices. – Eddwin Paz Nov 06 '18 at 13:39
  • @eddwinpaz, I do not understand your second comment. Would you expand it as an answer? I'm not sure why this is a backend question instead of iOS, I am writing an iOS app that needs to be a web socket server. – dumbledad Nov 06 '18 at 14:38
  • you need something like this https://github.com/benlodotcom/BLWebSocketsServer since StarScream its not a WebSocket Server Library. its a client library as im aware so far. – Eddwin Paz Nov 06 '18 at 14:40

0 Answers0