예제 #1
0
        /// <summary>Connects and logs Iris in to the specified GlobalMgrSvr.</summary>
        /// <param name="ip">The IP of the GlobalMgrSvr to connect to.</param>
        /// <param name="port">The port that the GlobalMgrSvr listens on.</param>
        /// <returns>TRUE if succeeded, else FALSE.</returns>
        public bool Connect(string ip, int port)
        {
            try
            {
                if (Globals.Client != null)
                {
                    Disconnect();
                    Globals.Client = null;
                }

                Globals.Client = new TcpClient();
                Globals.Client.Connect(ip, port);
                byte[] buf = new byte[0x2000];
                Globals.Client.Client.BeginReceive(buf, 0, 0x2000, SocketFlags.None, Receive, buf);

                packets.Send(PacketFactory.Handshake());

                return(true);
            }
            catch { return(false); }
        }
예제 #2
0
        /// <summary>
        /// Sends a GM message to the specified channel.
        /// <para>This message will display a notification at the bottom-right of each user's screen, which they can then click to show the whole message.</para>
        /// </summary>
        /// <param name="server">The ID of the server.</param>
        /// <param name="channel">
        /// The ID of the channel.
        /// <para>Use '0' to specify all channels.</para>
        /// </param>
        /// <param name="title">The title of the GM message.  Colours are NOT supported.</param>
        /// <param name="message">The message to broadcast.  Colours are supported.</param>
        /// <returns>TRUE if succeeded, else FALSE.</returns>
        public bool SendMessage(byte server, byte channel, string title, string message)
        {
            try
            {
                if (channel == 0)
                {
                    bool result = true;

                    foreach (var c in Globals.ServerList[server].Channels)
                    {
                        if (c.ChannelID != 0)
                        {
                            result = SendMessage(server, c.ChannelID, title, message) && result;
                        }
                    }

                    return(result);
                }

                return(packets.Send(PacketFactory.Message(server, channel, title, message)));
            }
            catch { return(false); }
        }
예제 #3
0
        /// <summary>
        /// Disconnects all players connected to the specified channel.
        /// <para>This is very useful if you plan on shutting down the server for maintenance, as it allows all users to be stored to the database, avoiding accidental rollbacks and loss of data.</para>
        /// </summary>
        /// <param name="server">The ID of the server.</param>
        /// <param name="channel">
        /// The ID of the channel.
        /// <para>Use '0' to specify all channels.</para>
        /// </param>
        /// <returns>TRUE if succeeded, else FALSE.</returns>
        public bool DisconnectPlayers(byte server, byte channel)
        {
            try
            {
                if (channel == 0)
                {
                    bool result = true;

                    foreach (var c in Globals.ServerList[server].Channels)
                    {
                        if (c.ChannelID != 0)
                        {
                            result = DisconnectPlayers(server, c.ChannelID) && result;
                        }
                    }

                    return(result);
                }

                return(packets.Send(PacketFactory.Disconnect(server, channel)));
            }
            catch { return(false); }
        }
예제 #4
0
 /// <summary>Sets the type of a channel.</summary>
 /// <param name="server">The server that the channel belongs to.</param>
 /// <param name="channel">The channel to edit.</param>
 /// <param name="type">The new channel type.</param>
 /// <returns></returns>
 public bool SetChannelType(byte server, byte channel, uint type)
 {
     try { return(packets.Send(PacketFactory.ChannelType(server, channel, type))); }
     catch { return(false); }
 }
예제 #5
0
 void heartbeat_Elapsed(object sender, ElapsedEventArgs e)
 {
     Send(PacketFactory.ServerList());
 }