Exemplo n.º 1
0
        private void BroadcastDisconnect()
        {
            var response = new SyncResponse(SyncResponse.ResponseTypes.Disconnect);

            response.Data = new { Reason = "Admin stopped server." };
            this.Broadcast(response.ToString());
        }
Exemplo n.º 2
0
        private void HandleCameraSyncProposal(UserContext context, SyncCommand command)
        {
            // Client requests OTHER clients to sync to his camera
            // Re-send data to clients
            var users = command.Data.Users.ToObject <List <User> >();
            //var users = (List<User>)JsonConvert.DeserializeObject<List<User>>(command.Data.Users.ToString());

            var response = new SyncResponse(SyncResponse.ResponseTypes.ProposeSyncCameras);

            response.Data = command.Data;
            var responseString = response.ToString();

            foreach (var user in users)
            {
                var conn = FindConnection(user);
                if (conn != null && conn.ClientAddress == context.ClientAddress.ToString())
                {
                    continue;                                                                         // skip requesting user
                }
                if (conn != null)
                {
                    conn.Context.Send(responseString);
                }
            }
        }
Exemplo n.º 3
0
        private void BroadcastUserlist()
        {
            var users = this.State.Users.ToList(); // _users.Where(u => u.IsRegistered).ToList();

            var response = new SyncResponse(SyncResponse.ResponseTypes.UserList);

            response.Data = new { Users = users };
            this.Broadcast(response.ToString());

            this.OnUpdateConnections();
        }
Exemplo n.º 4
0
        private void BroadcastState()
        {
            // Copy settings that clients require
            _state.OfftrackLimit = Properties.Settings.Default.OfftrackLimit;

            var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);

            response.Data = new { State = _state };
            Debug.WriteLine(">> Broadcasting state: " + response);

            this.Broadcast(response.ToString());
        }
Exemplo n.º 5
0
        private void SendState(UserContext context)
        {
            // Re-send the state if connected
            var conn = this.FindConnection(context);

            if (conn != null && conn.IsRegistered)
            {
                var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);
                response.Data = new { State = _state };
                context.Send(response.ToString());
            }
        }
Exemplo n.º 6
0
 private void BroadcastDisconnect()
 {
     var response = new SyncResponse(SyncResponse.ResponseTypes.Disconnect);
     response.Data = new {Reason = "Admin stopped server."};
     this.Broadcast(response.ToString());
 }
Exemplo n.º 7
0
        private void BroadcastState()
        {
            // Copy settings that clients require
            _state.OfftrackLimit = Properties.Settings.Default.OfftrackLimit;

            var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);
            response.Data = new { State = _state };
            Debug.WriteLine(">> Broadcasting state: " + response);

            this.Broadcast(response.ToString());
        }
Exemplo n.º 8
0
        private void BroadcastUserlist()
        {
            var users = this.State.Users.ToList(); // _users.Where(u => u.IsRegistered).ToList();
            
            var response = new SyncResponse(SyncResponse.ResponseTypes.UserList);
            response.Data = new { Users = users };
            this.Broadcast(response.ToString());

            this.OnUpdateConnections();
        }
Exemplo n.º 9
0
 private void Reply(UserContext context, SyncResponse response)
 {
     context.Send(response.ToString());
 }
Exemplo n.º 10
0
 private void SendState(UserContext context)
 {
     // Re-send the state if connected
     var conn = this.FindConnection(context);
     if (conn != null && conn.IsRegistered)
     {
         var response = new SyncResponse(SyncResponse.ResponseTypes.UpdateState);
         response.Data = new { State = _state };
         context.Send(response.ToString());
     }
 }
Exemplo n.º 11
0
        private void HandleCameraSyncProposal(UserContext context, SyncCommand command)
        {
            // Client requests OTHER clients to sync to his camera
            // Re-send data to clients
            var users = command.Data.Users.ToObject<List<User>>();
            //var users = (List<User>)JsonConvert.DeserializeObject<List<User>>(command.Data.Users.ToString());

            var response = new SyncResponse(SyncResponse.ResponseTypes.ProposeSyncCameras);
            response.Data = command.Data;
            var responseString = response.ToString();

            foreach (var user in users)
            {
                var conn = FindConnection(user);
                if (conn != null && conn.ClientAddress == context.ClientAddress.ToString()) continue; // skip requesting user
                if (conn != null)
                {
                    conn.Context.Send(responseString);
                }
            }
        }
Exemplo n.º 12
0
 private void Reply(UserContext context, SyncResponse response)
 {
     context.Send(response.ToString());
 }