/// <summary> /// Routine to close the socket connection. /// </summary> void DoClose() { _socket.Disconnect(); SocketEventManager.OnSocketDisconnected(); _socket = null; Connected = false; }
public override void OnMediaDownloaded(object sender, DownloadMediaEventArgs e) { if (e.DownloadGuid != MediaGuid) { return; } var eventArgs = e as DownloadAudioClipEventArgs; Audio = eventArgs.Clip; SocketEventManager.OnQueryRecieved(this); }
public override void OnMediaDownloaded(object sender, DownloadMediaEventArgs e) { SocketEventManager.OnQueryRecieved(this); }
/// <summary> /// Contains all routines to run when connecting to socket. /// </summary> public void ConnectToSocket() { // If already connected, do nothing. if (_socket != null) { return; } // By this point, the socket is null. Connected = false; //Create the socket instance. _socket = IO.Socket(ServerURL.SOCKET_IO); /// /// The section below is all of the socket events for the GCS to listen to. /// // When the socket connects. _socket.On(Socket.EVENT_CONNECT, () => { Debug.Log("Connected Event Received."); _socket.Emit("testee", "GCS Connected."); Connected = true; // Emit to the world that the socket has been connected. SocketEventManager.OnSocketConnected(); }); // When the socket disconnects. _socket.On(Socket.EVENT_DISCONNECT, () => { Debug.Log("Disconnect Event Received."); DoClose(); }); // Add listener for test data. _socket.On("tester", data => { Debug.Log("Testing Data Received:" + data); }); // When a query is received from the server. _socket.On(ServerURL.QUERY_RECEIVED, data => { Debug.Log(data); SocketEventManager.OnDataRecieved( new StringEventArgs { StringArgs = data.ToString() }); }); // Then the mission has been initialized. _socket.On(MissionLifeCycleController.MISSION_INITIALIZED, data => { Debug.Log("Mission Initialized Event Received."); EventManager.OnInitialized(); }); // When a query has been handled autonomously. _socket.On(ServerURL.AUTONOMOUS_QUERY, data => { Debug.Log("Autonomous Query Socket"); SocketEventManager.OnAutonomousQuery(data.ToString()); }); // When a query has been handled non autonomously. _socket.On(ServerURL.GENERATED_QUERY, data => { Debug.Log("Generated Query Socket"); SocketEventManager.OnQueryGenerated(data.ToString()); }); // When the mission has been started by the server. _socket.On(MissionLifeCycleController.MISSION_STARTED, data => { EventManager.OnStarted(); Debug.Log("Mission Started Event Received."); }); // When the mission has been stopped by the server. _socket.On(MissionLifeCycleController.MISSION_STOPPED, data => { EventManager.OnStopped(); Debug.Log("Mission Stopped Event Received."); }); // When a notification is received. _socket.On(ServerURL.NOTIFICATION_RECEIVED, data => { //EventManager.OnNotificationRecieved(new NotificationEventArgs { Notification = new Notification(data.ToString()) }); Debug.Log("Notification Event Reveicved."); }); }
void Awake() { Inst = this; }