Пример #1
0
        private void BroadcastTimerOnElapsed(object arg)
        {
            UdpManager tempUdpManager = UdpManager.GetInstance();

            tempUdpManager.Send(IPAddress.Broadcast, BroadcastPort, contentTcp);
            tempUdpManager.Send(IPAddress.Broadcast, BroadcastPort, contentUdp);
        }
        private void Awake()
        {
            var obj = new GameObject("UPD Manager");

            _udpManager          = obj.AddComponent <UdpManager>();
            obj.transform.parent = transform;
            _udpManager.AddCallback(UdpCallbackHandler);
        }
Пример #3
0
        public void Start()
        {
            UdpManager tempUdpManager = UdpManager.GetInstance();

            _udpClient = new UdpClient(new IPEndPoint(tempUdpManager.HostIpAddress, receiveImgPort));
            _udpClient.Client.ReceiveBufferSize = 10000000;
            _receiveThread = new Thread(Receive);
            _receiveThread.IsBackground = true;
            _receiveThread.Start();
        }
Пример #4
0
        public MainWindow()
        {
            DiscoveryManager = new DiscoveryManager(OnAgentAdded);
            UdpManager       = new UdpManager();

            _viewModel  = new MainWindowViewModel(DiscoveryManager);
            DataContext = _viewModel;

            InitializeComponent();
        }
Пример #5
0
    void Start()
    {
        UdpManager client = new UdpManager(SC.CLIENT);

        for (int i = 0; i < 20; i++)
        {
            client.Send(System.Text.Encoding.Unicode.GetBytes("客户端发来Test----" + i + "----"), m_RemotePoint);
        }

        client.Receive();
    }
Пример #6
0
            public void Init()
            {
                //Set the local UDP port
                UdpManager tempUdpManager = UdpManager.GetInstance();

                tempUdpManager.InitUdp(localPort, UdpReceiveCommand);

                //Generate the broadcast info
                _contentTcp = ("Server" + Separator + tempUdpManager.HostIpAddress + Separator + TcpServer.GetInstance().ServerPort + Separator + Environment.NewLine);

                //Set the timer
                TimerManager tempTimerManager = TimerManager.GetInstance();

                _timerGuid = tempTimerManager.AddTimer(BroadcastTimerOnElapsed, null, 0, 1000);
            }
Пример #7
0
    public IEnumerator WaitForServerCommands(int port)
    {
        roomPort = port;
        //to jest odpowiedzialne za poruszanie graczem
        //wysylasz swoj ruch i konczysz polaczenie
        //udpClient.SendRequestPlayerMove(playerMove, 58278);
        //laczysz sie z serwerem i sluchasz wiadomosci

        Debug.Log("<color=lime>START LISTENING</color>");
        udpClient = new UdpManager();
        udpClient.Connect(port);
        while (true)
        {
            string data = udpClient.waitForMessages(port);

            // data analysis
            if (data.Length > 0)
            {
                Debug.Log("<color=orange>Data acquired: '" + data + "'</color>");

                if (data.Contains("playerList"))    // player list
                {
                    Debug.Log("<color=orange>Acquired player list!</color>");
                    MainMenuController.Instance.RefreshPlayerNames(ResponseHandler.getArrayFromString(data));
                }
                else if (data.Contains("roomStart"))    // start game
                {
                    Debug.Log("Start game");
                    online = true;
                    MainMenuController.Instance.StartGame();
                }
                else if (data.Contains("ENDOFTURN"))
                {
                    Debug.Log("END OF TURN");
                    GameController.Instance.TurnEndedButtonPressed();
                }
            }

            yield return(null);

            //jak jakas przyjdzie mozesz dac break i znow SendRequestPlayerMove z twoim ruchem
        }
    }
Пример #8
0
        static void Main()
        {
            Task.Run(async() =>
            {
                if (!File.Exists("config.json"))
                {
                    File.Copy("config.default.json", "config.json");
                }
                Console.WriteLine("Loading Configuration");
                await ReloadConfiguration();
                Console.WriteLine("Starting Logger.");
                using var log = new LoggerConfiguration().WriteTo.Console().MinimumLevel.Is((LogEventLevel)Enum.Parse(typeof(LogEventLevel), Config.MinLogLevel, true)).CreateLogger();
                Log.Logger    = log;
                Log.Debug("Minimum log level is DEBUG. This may get spammy");
                Log.Information("Node Router Entry Point v{Version:0.00}", Version);
                Log.Information("---------------------------");
                if (Config.IsDefault)
                {
                    LoudMessage("The configuration has default values. Unset 'default' in config.json to remove this message");
                }

                if (Config.X509 == null)
                {
                    LoudMessage("No X509 Certificate is loaded. This entry point will transmit information insecurely. DO NOT USE IN PRODUCTION.");
                }
                else if (Config.CA == null)
                {
                    LoudMessage("No CA is defined. Identities of clients will not be verified. DO NOT USE IN PRODUCTION.");
                }
                await SslManager.Initialize();
                Log.Information("Registering handlers");
                NRL.Initialize();
                Routines.RegisterRoutines();
                Log.Information("Starting TCP server");
                _ = TcpManager.StartTCP();
                Log.Information("Starting UDP Listen on 2888");
                _ = UdpManager.StartUDP();
                await Task.Delay(-1);
            }).GetAwaiter().GetResult();
        }
Пример #9
0
        static void Main(string[] args)
        {
            //

            AddPlayer    player     = new AddPlayer("rooooooms", null, "playerNaameab"); // port do komunikacji zwraca w resultMessage() jako string;
            RoomCreation room       = new RoomCreation("playeeerr", "rooooooms", 3);
            RoomStart    start      = new RoomStart("roomnaaamex", "token", "abs");
            PlayerMove   playerMove = new PlayerMove();

            //udpClient.SendRequest<RoomStart>(start, 38621);

            //########## PIERW TO
            //RoomManager rm = new RoomManager(38621);
            //rm.addRoom("abs", "roomnaaame", 3);

            //########## POTEM TO Z NAZWA POKOJU CO ADDROOM
            //PlayerManager pm = new PlayerManager(38621);
            //pm.addPlayer("roomnaaame", null, "playernameA");


            //####### POTEM TO I WSZYSTKO DZIAŁA
            UdpManager udpClient = new UdpManager();
            RoomStart  start1    = new RoomStart("roomnaaamex", "token", "abs");

            Console.WriteLine(udpClient.SendRequest <RoomStart>(start1, 38621).isRequestSuccess());

            //to jest odpowiedzialne za poruszanie graczem
            //wysylasz swoj ruch i konczysz polaczenie
            //udpClient.SendRequestPlayerMove(playerMove, 58278);
            //laczysz sie z serwerem i sluchasz wiadomosci
            while (true)
            {
                //udpClient.waitForMessages(58278);
                //jak jakas przyjdzie mozesz dac break i znow SendRequestPlayerMove z twoim ruchem
            }
            Console.Read();
        }
Пример #10
0
        static void Main(string[] args)
        {
            #region Camera
            RaspberryCamera tempCamera = RaspberryCamera.GetInstance();
            tempCamera.StartStreaming(pictureSize, fps);
            Console.WriteLine("Init Camera --- success");
            #endregion

            #region Init UDP manager

            Console.Write("Init UDP manager");
            UdpManager tempUdpManager = UdpManager.GetInstance();
            tempUdpManager.InitUdp(LocalUdpPort, InterNetwork.UdpListenTaskDelegate);
            Console.WriteLine(" --- success");

            #endregion

            #region Init Serial Manager

            Console.Write("Init SERIAL manager ");
            SerialManager tempSerialManager = SerialManager.GetInstance();
            while (true)
            {
                string[] ports    = SerialManager.GetAllVaildPorts();
                bool     signFind = false;
                foreach (string i in ports)
                {
                    if (i.Contains("USB"))
                    {
                        SerialManager.SerialPortWithGuid portWithGuid = tempSerialManager.Add(i, BaudRate, Parity.None, RaspberrySerial.TargetDataReceivedEventHandler);
                        RaspberrySerial.PortGuid = portWithGuid.Guid;
                        RaspberrySerial.StartReceive(portWithGuid.Serial);
                        Console.Write("Select" + i);
                        signFind = true;
                        break;
                    }
                }
                if (!signFind)
                {
                    Console.WriteLine("The system is waiting for a serial port device");
                    Thread.Sleep(1000);
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(" --- success");
            #endregion
            if (Debugger.IsAttached)
            {
                while (true)
                {
                    Thread.Sleep(1000);
                }
            }

            Console.ReadLine();
            tempCamera.StopStreaming();
            StateManager.GetInstance().FindServer = false;
            tempSerialManager.GetPort(RaspberrySerial.PortGuid).Serial.Dispose();
            Environment.Exit(0);
        }
Пример #11
0
 public static UdpManager GetInstance(int _port)
 {
     return((Instance != null) ? Instance : Instance = Instance = new UdpManager(_port));
 }
Пример #12
0
 public static async Task UdpCDiscover(Packet pack)
 {
     byte[] ts = new UdpSDiscoverReply((uint)TcpManager.PortNumber, pack.Nonce, SslManager.Certificate).Build();
     await UdpManager.Transmit(pack.ClientAddress, ts);
 }
Пример #13
0
        public void BroadcastToInterNetwork(string data)
        {
            UdpManager tempUdpManager = UdpManager.GetInstance();

            tempUdpManager.Send(IPAddress.Broadcast, BroadcastPort, data);
        }
Пример #14
0
 private void Awake()
 {
     battleUiController = FindObjectOfType <BattleUiController>();
     udpManager         = FindObjectOfType <UdpManager>();
     matchModelStorage  = MatchModelStorage.Instance;
 }
Пример #15
0
 public void Destory()
 {
     CloseUdpClient();
     singleInstance = null;
 }
Пример #16
0
 public void Dispose()
 {
     UdpManager?.Dispose();
 }
Пример #17
0
 public CoreEsp8266()
 {
     UdpManager        = new UdpManager();
     DiscoveryManager  = new DiscoveryManager(UdpManager);
     DescriptorManager = new DescriptorManager(UdpManager);
 }
Пример #18
0
 public SubscribedDevice(UdpManager udpManager)
 {
     _udpManager     = udpManager;
     _timer          = new Timer(20.0);
     _timer.Elapsed += TimerOnElapsed;
 }
Пример #19
0
    void Start()
    {
        UdpManager server = new UdpManager(SC.SERVER);

        server.Receive();
    }