コード例 #1
0
 /// <summary>
 /// Disconnects the entire Mx client group, disconnecting
 /// all clients inside it.
 /// </summary>
 /// <param name="clientGroup">The client group.</param>
 public void Disconnect(MxClientGroup clientGroup)
 {
     foreach (var client in clientGroup.RealtimeClients.ToArray())
     {
         Disconnect(client);
     }
 }
コード例 #2
0
        /// <summary>
        /// Queue a packet for sending to the specified endpoint.
        /// </summary>
        /// <param name="group">
        /// The group to send the message to.
        /// </param>
        /// <param name="packet">
        /// The associated data to send.
        /// </param>
        /// <param name="reliable">
        /// Whether or not this message should be sent reliably and intact.  This also
        /// permits messages larger than 512 bytes to be sent.
        /// </param>
        public void Send(MxClientGroup group, byte[] packet, bool reliable = false)
        {
            if (group.Identifier == MxClientGroup.Ungrouped)
            {
                throw new InvalidOperationException(
                    "You must group clients before sending packets to them.  Either " +
                    "call PlaceInGroup immediately after Connect, or call PlaceInGroup " +
                    "in the ClientConnected handler.");
            }

            foreach (var client in group.RealtimeClients)
            {
                Send(client, packet, reliable);
            }
        }
コード例 #3
0
        /// <summary>
        /// Places the specified Mx client in the specified group.
        /// </summary>
        /// <param name="client">The Mx client.</param>
        /// <param name="identifier">The group identifier.</param>
        public MxClientGroup PlaceInGroup(MxClient client, string identifier)
        {
            if (client.Group.Identifier == identifier)
            {
                return client.Group;
            }

            if (!_mxClientGroups.ContainsKey(identifier))
            {
                _mxClientGroups[identifier] = new MxClientGroup(this, identifier);
            }

            var reliability = client.Group.ReliableClients.First(x => x.Client == client);

            client.Group.RealtimeClients.Remove(client);
            client.Group.ReliableClients.Remove(reliability);
            client.Group = _mxClientGroups[identifier];
            client.Group.RealtimeClients.Add(client);
            client.Group.ReliableClients.Add(reliability);

            return client.Group;
        }