public static void OnApplicationQuit() { Debug.Log("OnApplicationQuit"); ListenForTestOptionChanged.Stop(); ProtocolDataReader.Stop(); ForceSocket.Shutdown(); }
public ForceTransferredEventData(ForceSource forceSource, ForceSocket forceSocket, Vector2 dir, float stren, float t) { _source = forceSource; _socket = forceSocket; _direction = dir; _strength = stren; _time = t; }
public static void Stop() { if (_instance.alreadyStarted) { ForceSocket.IssueStopAndRemove(_instance.uuid, ForceSocket.KnownCommands.StopCOP); _instance.alreadyStarted = false; _instance.uuid = ""; } }
public static void Start() { if (!_instance.alreadyStarted) { _instance.alreadyStarted = true; ForceSocket.Start(); _instance.uuid = ForceSocket.IssuePerodicResponseCommand(ForceSocket.KnownCommands.StartCOP, new { UseCOG = false, Rate = 1000.0f / 30.0f },// 30 data frames per second _instance._OnData, typeof(COPData)); } }
private void OnOptionChanged(string s, object value) { switch (s) { case "speed": SpeedChanged(ForceSocket.toLowerString(value)); break; case "movementgain": MovementGainChanged(ForceSocket.toSingle(value)); break; case "swaygain": SwayGainChanged(ForceSocket.toSingle(value)); break; case "testtime": TestTimeChanged(ForceSocket.toInt(value)); break; case "obstacles": ObstaclesChanged(ForceSocket.toLowerString(value)); break; case "mstrooptest": mStroopTestChanged(ForceSocket.toLowerString(value)); break; case "mstroopobstacles": mStroopObstaclesChanged(ForceSocket.toBool(value)); break; case "displaytargetcircle": DisplayTargetCircleChanged(ForceSocket.toBool(value)); break; case "displaycogcursor": DisplayCOGCursorChanged(ForceSocket.toBool(value)); break; case "audiofeedback": AudioFeedbackChanged(ForceSocket.toBool(value)); break; case "heightmm": SubjectHeightChanged(ForceSocket.toSingle(value)); break; } }
/// <summary> /// Issues a command with a completion callback that takes a specific data type. /// </summary> /// <param name="command">the protocol-specific command to issue</param> /// <param name="parms">parms for the command</param> /// <param name="completionCallback">The method that should be invoked when the server returns back a result. The method will be called /// with the raw JSON string and object of the given dataType parsed from the JSON string.</param> /// <param name="datatype">The Type that the JSON parser should convert the incoming result data into. This new data object will be passed /// in the completionCallback's object parm</param> /// <returns>The UUID that was assigned to this command. Can be used for internal bookkeeping or for later use by RemoveCallback.</returns> public string IssueCommand(string command, object parms, Action <string, object> completionCallback, Type datatype) { ForceSocket.Start(); return(ForceSocket.IssueCommand(ForceSocket.KnownCommands.ProtocolCommand, concatCommandToParms(command, parms), completionCallback, datatype)); }
/// <summary> /// Issues a command with a completion callback that takes a generic object data type. /// </summary> /// <param name="command">the protocol-specific command to issue</param> /// <param name="completionCallback">The method that should be invoked when the server returns back a result. The method will be called /// with the raw JSON string and an generic object parsed from the JSON string.</param> /// <returns>The UUID that was assigned to this command. Can be used for internal bookkeeping or for later use by RemoveCallback.</returns> public string IssueCommand(string command, Action <string, object> completionCallback) { ForceSocket.Start(); return(ForceSocket.IssueCommand(ForceSocket.KnownCommands.ProtocolCommand, concatCommandToParms(command, null), completionCallback)); }
// /// <summary> /// Issues a command with parms and no completion callback. Aka InvokeMethod /// </summary> /// <param name="command">the protocol-specific command to issue</param> /// <param name="parms">parms for the command</param> public void IssueCommand(string command, object parms) { ForceSocket.Start(); ForceSocket.IssueCommand(ForceSocket.KnownCommands.ProtocolCommand, concatCommandToParms(command, parms)); }
/// <summary> /// Stops the given periodic response by issuing a stop command to the server and removing the registered callback from the table. /// </summary> /// <param name="uuid"></param> /// <returns></returns> public void StopListener(string uuid) { ForceSocket.IssueStopAndRemove(uuid, ForceSocket.KnownCommands.StopProtocolCommand); }
/// <summary> /// Issues a command with a periodic completion callback that takes a generic object data type. /// </summary> /// <param name="command">the protocol-specific command to issue</param> /// <param name="parms">parms for the command</param> /// <param name="completionCallback">The method that should be invoked when the server returns back a result. The method will be called /// with the raw JSON string and object of the given dataType parsed from the JSON string.</param> /// <param name="datatype">The Type that the JSON parser should convert the incoming result data into. This new data object will be passed /// in the completionCallback's object parm</param> /// <returns>The UUID that was assigned to this command. Can be used for internal bookkeeping or for later use by RemoveCallback.</returns> public string StartListener(string command, object parms, Action <string, object> completionCallback) { ForceSocket.Start(); return(ForceSocket.IssuePerodicResponseCommand(ForceSocket.KnownCommands.ProtocolCommand, concatCommandToParms(command, parms), completionCallback)); }