Created
October 20, 2015 09:21
-
-
Save ggarber/e8c7a490afd7eae2f97d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onConnectionCreate(connection) | |
if (session.connections.count > X) { | |
throw new Exception(); | |
} | |
session.connections.add(connection) | |
session.connections.each((connection) => connections.send(notification)) | |
onConnectionDestroy(connection) | |
session.streams.remove((stream) => stream.connection == connection) | |
session.subscribers.remove((subscriber) => subscriber.stream.connection == connection) | |
session.connections.remove(connection) | |
session.connections.each((connection) => connections.send(notification)) | |
onStreamCreate(stream) | |
if (session.streams.count > X) { | |
throw new Exception(); | |
} | |
session.streams.add(stream) | |
session.connections.each((connection) => connections.send(notification)) | |
onStreamDestroy(stream) | |
session.streams.remove(stream) | |
session.subscribers.remove((subscriber) => subscriber.stream == stream) | |
session.connections.each((connection) => connections.send(notification)) | |
session.archives((archive) => archive.streams.remove(stream)) | |
onSignal(signal) | |
session.connections.each((connection) => connections.send(signal)) | |
// These 2 methods are slightly different for P2P and Mantis and slightly different for publishers and subscribers | |
onJSEPMessage(stream, msg) | |
onMantisMessage(stream, msg) | |
FSM[stream].apply(msg) | |
FSM[stream].closed += sessions.streams.remove(stream) | |
FSM[stream].active += sessions.streams.remove(stream) | |
FSM[stream].congestion += () { | |
sessions.connections[stream.connection].send(msg) | |
sessions.streams.remove(stream) | |
} | |
// Maybe we could live without this functionality | |
onMantisDown() | |
sessions.each((session) => session.close()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment