Exemplo n.º 1
0
        public ClickGame(ClickGameConfiguration config, GameCreationPayload payload)
        {
            _config = config;
            IReadOnlyCollection <IPlayer> players = payload.PlayerToRole.Keys.ToArray();

            _allPlayers = new MulticastGroup(players);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Suspends the listening for incoming PDU's.
        /// </summary>
        /// <param name="pdu">The <see cref="DIS.Dis1998.IMarshallable"/> PDU to be transmitted</param>
        /// <param name="group">The <see cref="DIS.Utilties.Networking.MulticastGroup"/> to send this PDU to.</param>
        public void sendPDU(IMarshallable pdu, MulticastGroup group)
        {
            DataOutputStream dos = new DataOutputStream(Endian.Big);

            pdu.MarshalAutoLengthSet(dos);
            byte[] data = dos.ConvertToBytes();
            UdpClient.Send(data, data.Length, new IPEndPoint(group.Address, Port));
        }
Exemplo n.º 3
0
        public void Demonstrate()
        {
            Console.WriteLine("[SENDER - INFO] Started sending example");
            //Marnehuizen
            double lat = 53.3889139;
            double lon = 6.263677777777778;

            EntityStatePdu espdu = new EntityStatePdu();

            espdu.ExerciseID = 1;

            EntityID eid = espdu.EntityID;

            eid.Site        = 0;
            eid.Application = 1;
            eid.Entity      = 2;

            EntityType entityType = espdu.EntityType;

            entityType.Country     = (ushort)Country.Netherlands; // NL
            entityType.EntityKind  = (byte)EntityKind.LifeForm;   // Life form (vs platform, munition, sensor, etc.)
            entityType.Domain      = (byte)Platform.Land;         // Land (vs air, surface, subsurface, space)
            entityType.Category    = 0;                           //empty
            entityType.Subcategory = 1;                           // Dismounted
            entityType.Specific    = 5;                           //carrying an assault rifle
            entityType.Extra       = 1;                           //Moving alone

            while (true)
            {
                lat += (1d / 11132000);
                lon += (1d / 40075) * Math.Cos(lat) / 360d;
                double[] disCoordinates = CoordinateConversions.getXYZfromLatLonDegrees(lat, lon, 0.0);

                Console.WriteLine("[SENDER - INFO] Entity is now at (lat:{0}, long:{1}", lat, lon);

                Vector3Double location = espdu.EntityLocation;
                location.X      = disCoordinates[0];
                location.Y      = disCoordinates[1];
                location.Z      = disCoordinates[2];
                espdu.Timestamp = DisTime.DisRelativeTimestamp;

                //send the constructed PDU to the specified multicast group
                _connector.sendPDU(espdu, MulticastGroup.Parse("224.5.5.5"));
                Console.WriteLine("[SENDER - INFO] PDU broadcasted");

                Thread.Sleep(15000);
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            //get an instance of the connector from the factory
            Connector conn = ConnectorFactory.getInstance(6400);

            //then join a multicast group of your choice to send and receive PDU's from/to
            conn.JoinMulticastGroup(MulticastGroup.Parse("224.5.5.5"));

            IExample sendingExample, receivingExample;

            sendingExample   = new SendingExample(conn);
            receivingExample = new ReceivingExample(conn);

            Thread t1 = new Thread(new ThreadStart(sendingExample.Demonstrate));
            Thread t2 = new Thread(new ThreadStart(receivingExample.Demonstrate));

            t1.Start();
            t2.Start();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Enables multicasting PDU's to specified address, and receive PDU's likewise.
 /// sent from that address.
 /// </summary>
 /// <param name="group">The multicast group, ranging from 224.0.0.0 to 239.255.255.255.</param>
 public void JoinMulticastGroup(MulticastGroup group)
 {
     UdpClient.JoinMulticastGroup(group.Address, 50);
 }