コード例 #1
0
        private void StartSimulationOnConnectedPeers()
        {
            var writer = new Serializer();

            //Create a new seed and send it with a start-message to all clients
            //The message also contains the respective player-id and the servers' frame rate
            var seed = new Random().Next(int.MinValue, int.MaxValue);

            foreach (var player in _playerIds)
            {
                writer.Reset();
                writer.Put((byte)MessageTag.StartSimulation);
                new Init
                {
                    Seed      = seed,
                    ActorID   = player.Value,
                    AllActors = _playerIds.Values.ToArray(),
                    TargetFPS = TargetFps
                }.Serialize(writer);

                _server.Send(player.Key, Compressor.Compress(writer));
            }
        }
コード例 #2
0
 protected override void OnReceiveMessage(IServer server, ISession session, object message)
 {
     // Console.WriteLine(message);
     server.Send($"hello {message}", session);
 }
コード例 #3
0
 protected override void OnReceiveMessage(IServer server, ISession session, object message)
 {
     ((Messages.Register)message).DateTime = DateTime.Now;
     server.Send(message, session);
 }