コード例 #1
0
        public override void Init()
        {
            const string appId        = "MonoDragons Network Test";
            const int    port         = 44558;
            var          networkTypes = new [] { typeof(DemoMessage) };

            _host = JsonNetGame.Host(appId, port, networkTypes);
            Add(_log);
            Add(_host);
            Add(MakeButton("Host", new Point(400, 10), () => _host.Init()));
            Add(MakeButton("Connect", new Point(400, 100), () => AddNewConnection(appId, port, networkTypes)));
            Add(MakeButton("Disconnect", new Point(400, 200), Disconnect));
            Add(MakeButton("Send Client Message", new Point(400, 300), SendClientMessage));
            Add(MakeButton("Send Host Message", new Point(400, 400), SendHostMessage));
            Add(MakeButton("Clear Log", new Point(400, 500), () => _log.Clear()));
            Add(() => _clients.ForEach(x => x.Update(TimeSpan.Zero)));
            Event.Subscribe <DemoMessage>(e => Logger.WriteLine(e.Message), this);
        }
コード例 #2
0
 public static void HostGame(string appId, int port, params Type[] types)
 => Net.Init(JsonNetGame.Host(appId, port, types).Initialized());
コード例 #3
0
 public static void JoinGame(string appId, string host, int port, params Type[] types)
 => Net.Init(JsonNetGame.ConnectTo(appId, host, port, types).Initialized());
コード例 #4
0
 private void AddNewConnection(string appId, int port, Type[] types)
 {
     _clients = _clients.Append(JsonNetGame.ConnectTo(appId, "127.0.0.1", port, types).Initialized());
 }