コード例 #1
0
        public void OnOpenWebSocket(IWebSocketConnection _socket)
        {
            string           path    = _socket.ConnectionInfo.Path;
            var              manager = addConnectionManager(path, service_list);
            WebSocketService service = NewServiceMap(manager, _socket);

            manager.addMember(service);
        }
コード例 #2
0
        public void Open(IWebSocketConnection _socket)
        {
            WebSocketService service = memberList.Find((_temp) =>
            {
                return(_temp.ID == _socket.ConnectionInfo.Id.ToString());
            });

            if (service != null)
            {
                ((IServicePlus)service).MCOpen();
            }
        }
コード例 #3
0
        public void FMSend(string data, string _id)
        {
            WebSocketService service = memberList.Find((_temp) =>
            {
                return(_id == _temp.ID);
            });

            if (null != service)
            {
                //service.Send(data);
                ((IServicePlus)service).FMSend((command)JsonConvert.DeserializeObject(data, typeof(command)));
            }
        }
コード例 #4
0
        public void removeMember(string _id)
        {
            WebSocketService service = memberList.Find((_temp) =>
            {
                return(_id == _temp.ID);
            });

            if (null != service)
            {
                service.OnClose();
                this.memberList.Remove(service);
                Debug.WriteLine("***** MClient -- count => " + memberList.Count.ToString());
            }
        }
コード例 #5
0
        public void OnMessage(string message, IWebSocketConnection _socket)
        {
            WebSocketService service = memberList.Find((_temp) =>
            {
                return(_temp.ID == _socket.ConnectionInfo.Id.ToString());
            });

            if (service != null)
            {
                service.OnMessage(message);
            }
            //_socket.Send("private =>" + message);
            //Broadcast("public => " + message);
        }
コード例 #6
0
        public bool addMember(WebSocketService _service)
        {
            if (null == _service) return false;

            WebSocketService service = memberList.Find((_con) =>
            {
                return _service.ID == _con.ID;
            });
            if (null == service)
            {
                this.memberList.Add(_service);
                _service.OnOpen();
                Debug.WriteLine(" ++ count => " + memberList.Count.ToString());
                return true;
            }
            return false;
        }
コード例 #7
0
        public void MCOnMessage(string message, IWebSocketConnection _socket)
        {
            WebSocketService service = memberList.Find((_temp) =>
            {
                return(_temp.ID == _socket.ConnectionInfo.Id.ToString());
            });

            if (service != null)
            {
                command cmd_temp = (command)JsonConvert.DeserializeObject(message, typeof(command));
                cmd_temp.id = _socket.ConnectionInfo.Id.ToString();
                //service.OnMessage(JsonConvert.SerializeObject(cmd_temp));
                ((IServicePlus)service).MCOnMessage(cmd_temp);
            }
            //_socket.Send("private =>" + message);
            //Broadcast("public => " + message);
        }
コード例 #8
0
        public bool addMember(WebSocketService _service)
        {
            if (null == _service)
            {
                return(false);
            }

            WebSocketService service = memberList.Find((_con) =>
            {
                return(_service.ID == _con.ID);
            });

            if (null == service)
            {
                this.memberList.Add(_service);
                _service.OnOpen();
                Debug.WriteLine("***** MClient ++ count => " + memberList.Count.ToString());
                return(true);
            }
            return(false);
        }
コード例 #9
0
        public WebSocketService NewServiceMap(WebSocketServiceManager _manager, IWebSocketConnection socket)
        {
            WebSocketService service = null;

            switch (_manager.managerName)
            {
            case "/gps":
                service = new GPSService(_manager, socket);
                //service.
                break;

            case "/uhf":
                service = new UHFService(_manager, socket);
                break;

            case "/green_light":
                service = new GreenLightService(_manager, socket);
                break;

            case "/red_light":
                service = new RedLightService(_manager, socket);
                break;

            case "/yellow_light":
                service = new YellowLightService(_manager, socket);
                break;

            case "/fan":
                service = new FanService(_manager, socket);
                break;

            case "/engine":
                service = new EngineService(_manager, socket);
                break;
            }
            return(service);
        }
コード例 #10
0
        public WebSocketService NewServiceMap(WebSocketServiceManager _manager, IWebSocketConnection socket)
        {
            WebSocketService service = null;

            switch (_manager.managerName)
            {
            case "/" + TargetDeiveName.GPS:
                service = new GPSService(_manager, socket);
                break;

            case "/" + TargetDeiveName.UHF:
                service = new UHFService(_manager, socket);
                break;

            case "/" + TargetDeiveName.绿灯:
                service = new GreenLightService(_manager, socket);
                break;

            case "/" + TargetDeiveName.红灯:
                service = new RedLightService(_manager, socket);
                break;

            case "/" + TargetDeiveName.黄灯:
                service = new YellowLightService(_manager, socket);
                break;

            case "/" + TargetDeiveName.电风扇:
                service = new FanService(_manager, socket);
                break;

            case "/" + TargetDeiveName.电机:
                service = new EngineService(_manager, socket);
                break;
            }
            return(service);
        }
コード例 #11
0
ファイル: services.cs プロジェクト: ssor/iotlab-native
 public static void register_service(string name, WebSocketService wss)
 {
     service_dic[name] = wss;
 }