public HastyClient(Uri serverUrl, string realm, string username, string password, CommandDefinitions definitions, string baseDir, object target, ILog log) { this.username = username; this.password = password; this.realm = realm; this.log = log.CreateLog(typeof(HastyClient)); var storage = new StreamStorage(baseDir, log); preferences = new Preferences(baseDir, log); streamStorage = storage; this.definitions = definitions; defaultTarget = target; SetStatus(ConnectionStatus.Idle); SetState(ConnectionState.Establishing); connectionMaintainer = new ConnectionMaintainer(serverUrl, realm, log); connectionMaintainer.OnPacketRead += OnPacketRead; connectionMaintainer.OnDisconnect += OnDisconnect; connectionMaintainer.OnConnecting += OnConnecting; connectionMaintainer.OnConnected += OnMaintainerConnected; ulong userAssignedChannelId; var foundUserAssignedChannel = preferences.GetUserChannel(serverUrl.ToString(), realm, out userAssignedChannelId); if (foundUserAssignedChannel) { Subscribe((uint)userAssignedChannelId, target); } connectionMaintainer.Start(); }
// Use this for initialization void Start () { DontDestroyOnLoad (gameObject); guiLoginPanelScript = GetComponent<GUILoginPanel> (); if (connectionMaintainer == null) { connectionMaintainer = new ConnectionMaintainer(hostname, port); } if (connectionMaintainer.running == false) { Thread t = new Thread(new ThreadStart(connectionMaintainer.RunReader)); t.Start(); } }
public void AddListener(string className, OnMessage eventListener) { if(connectionMaintainer == null) { connectionMaintainer = new ConnectionMaintainer(hostname, port); } if(!connectionMaintainer.eventListeners.ContainsKey(className)) { connectionMaintainer.eventListeners[className] = new List<OnMessage>(); } connectionMaintainer.eventListeners [className].Add (eventListener); }
public WebSocketMessageHandler(ConnectionMaintainer cm) { this._connectionMaintainer = cm; WebSocketClient = new WebSocketClient(this); WebSocketServer = new WebSocketServer(this); }