2019-04-24 16:20:31 +00:00
|
|
|
import * as plugins from './smartuniverse.plugins';
|
|
|
|
import { UniverseChannel } from './smartuniverse.classes.universechannel';
|
|
|
|
|
|
|
|
/**
|
2019-04-30 17:16:03 +00:00
|
|
|
* represents a connection to the universe
|
2019-04-24 16:20:31 +00:00
|
|
|
*/
|
|
|
|
export class UniverseConnection {
|
2019-06-07 09:49:10 +00:00
|
|
|
public terminatedDeferred = plugins.smartpromise.defer();
|
|
|
|
|
|
|
|
|
2019-04-24 16:20:31 +00:00
|
|
|
/**
|
|
|
|
* the socketClient to ping
|
|
|
|
*/
|
2019-06-06 21:23:37 +00:00
|
|
|
public socketConnection: plugins.smartsocket.SocketConnection;
|
2019-06-07 09:49:10 +00:00
|
|
|
public authenticationRequests = [];
|
2019-06-06 21:23:37 +00:00
|
|
|
public subscribedChannels: UniverseChannel[] = [];
|
|
|
|
public authenticatedChannels: UniverseChannel[] = [];
|
|
|
|
public failedToJoinChannels: UniverseChannel[] = [];
|
2019-04-24 16:20:31 +00:00
|
|
|
|
2019-06-07 09:49:10 +00:00
|
|
|
/**
|
|
|
|
* terminates the connection
|
|
|
|
*/
|
2019-06-06 21:23:37 +00:00
|
|
|
public terminateConnection () {
|
2019-06-07 09:49:10 +00:00
|
|
|
this.socketConnection.socket.disconnect();
|
|
|
|
this.terminatedDeferred.resolve();
|
2019-06-06 21:23:37 +00:00
|
|
|
}
|
2019-04-24 16:20:31 +00:00
|
|
|
|
2019-06-06 21:23:37 +00:00
|
|
|
constructor(optionsArg: {
|
|
|
|
socketConnection: plugins.smartsocket.SocketConnection;
|
2019-06-07 09:49:10 +00:00
|
|
|
authenticationRequests
|
2019-06-06 21:23:37 +00:00
|
|
|
}) {
|
2019-06-10 15:46:06 +00:00
|
|
|
// TODO: check if this is correct
|
|
|
|
this.socketConnection.socket.disconnect();
|
2019-04-24 16:20:31 +00:00
|
|
|
}
|
2019-06-06 21:23:37 +00:00
|
|
|
}
|