예제 #1
0
파일: App.cs 프로젝트: GameHole/CoreServer
        static void Main(string[] args)
        {
            token = new  CancellationTokenSource();
            token.Token.Register(() =>
            {
                Console.WriteLine("App::Quit");
            });
            WorldInitialer.Load(World.Active, typeof(World));
            WorldInitialer.Load(World.Active, typeof(App));
            var socket = World.Active.Globel.AddComponent <WebSocketServerComponent>();

            socket.Init(10000);
            Console.WriteLine("Start::ws://" + socket.listener.Address + ":" + socket.listener.Port + "/");
            World.Active.RunAsync(RunTick, token.Token);
            while (true)
            {
                string cos = Console.ReadLine();
                switch (cos)
                {
                case "quit":
                    token.Cancel();
                    return;
                }
            }
        }
예제 #2
0
파일: App.cs 프로젝트: GameHole/CoreServer
 static void Run()
 {
     WorldInitialer.Load(World.Active, typeof(World));
     WorldInitialer.Load(World.Active, typeof(App));
     WorldInitialer.Load(World.Active, typeof(UdpInit));
     World.Active.GetBehavior <UdpInit>().Load(typeof(App)).Init(10000);
     World.Active.Globel.GetComponent <ConnectorsComponent>().AsServer();
     World.Active.GetBehavior <UdpRecever>().Run();
 }
예제 #3
0
    async void Awake()
    {
        world = World.Active;
        DontDestroyOnLoad(gameObject);
        WorldInitialer.Load(world, typeof(ClientWorld));
        //WorldInitialer.Load(world, typeof(UdpInit));
        world.GetBehavior <UdpInit>().Load(typeof(ClientWorld)).Init();
        world.Globel.GetComponent <ConnectorsComponent>().AsClient();
        world.GetBehavior <UdpRecever>().Run();
        var send = world.GetBehavior <UdpSender>();

        if (await send.Connect("game", "127.0.0.1", 10000) == 0)
        {
            Debug.Log("connected");
        }
    }
예제 #4
0
파일: App.cs 프로젝트: GameHole/CoreServer
        static async void Run()
        {
            WorldInitialer.Load(World.Active, typeof(World));
            WorldInitialer.Load(World.Active, typeof(App));
            WorldInitialer.Load(World.Active, typeof(UdpInit));
            World.Active.GetBehavior <UdpInit>().Load(typeof(App)).Init();
            World.Active.Globel.GetComponent <ConnectorsComponent>().AsClient();
            World.Active.GetBehavior <UdpRecever>().Run();

            var sender = World.Active.GetBehavior <UdpSender>();

            if (await sender.Connect("game", "127.0.0.1", 10000) >= 0)
            {
                Console.WriteLine("Connected");

                sender.Send("game", new MatchReq());
            }
        }