-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add some docs #1
Comments
Hey, do you think this small readme and the ScalaDoc are enough? |
Yes, it is better now. |
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. |
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
The text was updated successfully, but these errors were encountered: