예제 #1
0
 /// <summary>
 /// Creates controller proxy and establishes connection.
 /// </summary>
 /// <param name="endpointAddress">
 /// Endpoint address (ip:port). <see cref="APIClient.ConnectToControllerProxy">Should be requested from control connection</see>.
 /// </param>
 /// <param name="keepAlive">
 /// True if automatic pings should keep connection alive even if caller doesn't send data.
 /// </param>
 public ControllerProxy(string endpointAddress, bool keepAlive = false)
     : base(endpointAddress, keepAlive)
 {
     controller = new ControllerStateRequest()
     {
         Origin   = (byte)ControllerOrigin.Zero,
         TaskType = (byte)ControllerTask.SendFullState
     };
 }
예제 #2
0
 /// <summary>
 /// Creates controller proxy and establishes connection.
 /// </summary>
 /// <param name="endpointAddress">
 /// Endpoint address (ip:port). <see cref="APIClient.ConnectToControllerProxy">Should be requested from control connection</see>.
 /// </param>
 /// <param name="keepAlive">
 /// True if automatic pings should keep connection alive even if caller doesn't send data.
 /// </param>
 public ControllerProxy(string endpointAddress, bool keepAlive = false)
     : base(endpointAddress, keepAlive)
 {
     controller = new ControllerStateRequest()
     {
         TaskType = (byte)ControllerTask.SendFullState,
         Version  = ControllerStateRequest.CurrentVersion
     };
 }
예제 #3
0
        /// <summary>
        /// Disconnected from controller API and frees the API for other clients.
        /// </summary>
        public void Disconnect()
        {
            var disconnectRequest = new ControllerStateRequest()
            {
                TaskType = (byte)ControllerTask.Disconnect
            };

            try
            {
                SendMessage(disconnectRequest);
            }
            catch (TimeoutException)
            {
                // Connection probably dropped another way, ignoring
            }
            catch (FiniteStateMachineException)
            {
                // Connection state invalid, close anyway
            }
            CloseSocket();
        }
예제 #4
0
 private ControllerStateResponse SendMessage(ControllerStateRequest obj) => SendMessage <ControllerStateResponse>(obj);