Open antonkulaga opened 9 years ago
Hey, do you think this small readme and the ScalaDoc are enough?
Yes, it is better now. It would be nice to see some explanations of core concepts to make it easier to get started with WebRTC video chats ( not only one 2 one but also in one 2 many and many 2 many video broadcasting configurations) as not all things are clear from examples
The library only supports WebRTC data channels, which is limited to the exchange of strings.
Regarding general message broadcast, there is nothing included in the library either. OOTB Transports are only one-to-one links that have functionality added on top of the implementation.
Regarding general message broadcast, there is nothing included in the library either.
It would be nice to have something. For instance in case of WebRTC datachannels it can be used to exchange data directly between clients ommiting the server, in such case one-2-many broadcasting will be usefull.
Something like this?
/** Combines several connections passed in arguments and returns the resulting broadcast
* connection. Messages send through the broadcast are copied and sent over each of the
* combined connections. Messages received from any of the combined connections are
* forwarded to the broadcast connection. Closing the broadcast connection closes all
* combined connections, and the broadcast connection is closed when when any of the
* combined connection is closed. */
def trivialBroadcast(cs: ConnectionHandle*)(implicit ec: ExecutionContext): ConnectionHandle = {
val queueablePromise = QueueablePromise[MessageListener]
val closePromise = Promise[Unit]
cs.foreach(_.handlerPromise.success(message => queueablePromise.queue(_(message))))
cs.foreach(_.closedFuture.foreach(_ => closePromise.trySuccess(())))
new ConnectionHandle {
def handlerPromise: Promise[MessageListener] = queueablePromise
def write(message: String): Unit = cs.foreach(_.write(message))
def closedFuture: Future[Unit] = closePromise.future
def close(): Unit = cs.foreach(_.close())
}
}
I feel that any real life application would need something way more complicated that this, for instance if any kind of consistency is needed, and I'm sure if something that simple would be useful to anyone.
Please, add some docs