Example #1
0
        public void InitNcConnection(CString ncip, CString ncport)
        {
            this.form         = Abstraction.GetInstance();
            this.serverWindow = ServerWindow.GetInstance();

            // Connect to GServer

            //NCConn.RunServer();

            //GSConn.Disconnect();
            if (!NCConn.Connected)
            {
                this.form.WriteText("Connecting to NpcServer...");
                this.form.WriteText("Address:\t" + ncip.Text);
                this.form.WriteText("Port:\t\t" + ncport.ToString());
                NCConn.Connect(ncip.Text, ncport.ToInt());
            }
            else
            {
                this.form.WriteText("Already connected!");
            }

            if (NCConn.Connected)
            {
                this.form.WriteText("Connected!");
                NCConn.SendLogin(this.username, this.password);
            }
        }
        private void LoginButton_Click(object sender, EventArgs e)
        {
            if (this.settings != null)
            {
                this.settings.Account  = this.username_ent.Text;
                this.settings.Password = this.password_ent.Text;
                if (!this.settings2.Loaded)
                {
                    this.settings.Nickname = this.nickname_ent.Text;
                }
                else
                {
                    this.settings2.Nickname = this.nickname_ent.Text;
                }
                this.settings.RCMode = this.checkBox2.Active;

                this.settings.Addresses = this.settings.Addresses;
                this.settings.Port      = this.settings.Port;
            }

            this.serverWindow = ServerWindow.GetInstance();
            this.serverWindow.Build();
            this.serverWindow.ShowAll();

            this.Hide();
        }
        /*
         * public void tabPage_Disposed(object sender, ControlEventArgs e)
         * {
         *      TabPage tabPage = (TabPage)sender;
         *      this.IRC_ChatWindowText("tabPage2", "(Me) " + "-Serverlist_Chat,irc,part," + tabPage.Name + "\n");
         *      this.Server.SendGSPacket(new CString() + (byte)154 + "-Serverlist_Chat,irc,part," + tabPage.Name + "\n");
         * }
         */
        protected void formclosed(object o, EventArgs args)
        {
            this.Server.CloseServers();

            ServerWindow serverWindow = ServerWindow.GetInstance();

            serverWindow.Show();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 public ListServerConnection(Gtk.ListStore listStore)
 {
     this.serverWindow = ServerWindow.GetInstance();
     this.listStore = listStore;
     this.serverList = new TServerList();
     this.errorWindow = ErrorWindow.GetInstance();
     //this.errorWindow.ShowAll();
     //this.errorWindow.Hide();
     //this.ReceiveData();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 public ListServerConnection(Gtk.ListStore listStore)
 {
     this.serverWindow = ServerWindow.GetInstance();
     this.listStore    = listStore;
     this.serverList   = new TServerList();
     this.errorWindow  = ErrorWindow.GetInstance();
     this.loginWindow  = LoginWindow.GetInstance();
     //this.errorWindow.ShowAll();
     //this.errorWindow.Hide();
     //this.ReceiveData();
 }
Example #6
0
        public void RunServer()
        {
            this.Build();

            this.bg      = new global::Gtk.Image();
            this.bg.Name = "bg";

            this.bg.Pixbuf = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rc_images.rc_opengraal.jpg");

            if (this.rcSettings.Loaded)
            {
                if (System.IO.File.Exists("skins/" + this.rcSettings.Background))
                {
                    this.bg.Pixbuf = new Gdk.Pixbuf("skins/" + this.rcSettings.Background);
                }
            }

            this.bg.SetAlignment(0, 0);
            this.bg.HeightRequest = 160;

            this.SizeRequested += OnResize;
            this.table3.Add(this.bg);

            global::Gtk.Table.TableChild w4 = ((global::Gtk.Table.TableChild)(this.table3[this.bg]));
            w4.BottomAttach = ((uint)(0));


            //this.ResizeChecked += OnResize;
            //this.SizeRequested += OnResize;
            this.CreateButtons();

            this.Framework       = Framework.GetInstance();
            this.PMWindowManager = PMWindowList.GetInstance();
            this.DeleteEvent    += delegate
            {
                this.Framework.CloseServers();

                ServerWindow serverWindow = ServerWindow.GetInstance();
                serverWindow.Show();
            };
            this.DestroyEvent += delegate
            {
                this.Framework.CloseServers();

                ServerWindow serverWindow = ServerWindow.GetInstance();
                serverWindow.Show();
            };
            this.ShowAll();
        }
		private void LoginButton_Click(object sender, EventArgs e)
		{
			if (this.settings != null)
			{
				this.settings.Account = this.username_ent.Text;
				this.settings.Password = this.password_ent.Text;
				if (!this.settings2.Loaded)
					this.settings.Nickname = this.nickname_ent.Text;
				else
					this.settings2.Nickname = this.nickname_ent.Text;
				this.settings.RCMode = this.checkBox2.Active;

				this.settings.Addresses = this.settings.Addresses;
				this.settings.Port = this.settings.Port;
			}

			this.serverWindow = ServerWindow.GetInstance();
			this.serverWindow.Build();
			this.serverWindow.ShowAll();

			this.Hide();
		}
Example #8
0
        /*
        /// <summary>
        /// Accept incoming connection for NPC-Control
        /// </summary>
        /// <param name="ar"></param>
        protected void NCControl_Accept(IAsyncResult ar)
        {
            // Accept Socket
            NCConnection Client = new NCConnection(this, (Socket)NCListen.EndAcceptSocket(ar));
            Client.ReceiveData();
            NCList.Add(Client);

            // Listen for incoming connections
            NCListen.BeginAcceptSocket(cNCAccept, NCListen);
        }
        */
        /// <summary>
        /// Run NPC Server
        /// </summary>
        public void RunServer()
        {
            // Run Timeouts
            /*
            foreach (KeyValuePair<String, ServerWeapon> wep in WeaponList)
            {
                ScriptObj obj = (ScriptObj)wep.Value.ScriptObject;
                if (obj != null)
                    obj.RunEvents();
            }

            // Level-Npcs
            lock (TimerLock)
            {
                foreach (KeyValuePair<String, GraalLevel> lvl in LevelList)
                {
                    foreach (KeyValuePair<int, GraalLevelNPC> npc in lvl.Value.NpcList)
                    {
                        ScriptObj obj = (ScriptObj)npc.Value.ScriptObject;
                        if (obj != null)
                            obj.RunEvents();
                    }
                }
            }

            while (Compiler.RunList.Count > 0)
            {
                IRefObject obj;
                lock (Compiler.RunList)
                    obj = Compiler.RunList.Dequeue();
                obj.Call("onCreated", null);
            }
            */
            this.form = Abstraction.GetInstance();

            this.form.Activate();
            this.form.WriteText("--- OpenGraal Instant Messenger / Remote Control ---");
            this.serverWindow = ServerWindow.GetInstance();
            // Default PM
            this.NCMsg = CString.tokenize("I am the Framework for\nthis game server. Almost\nall npc actions are controled\nby me.");

            // Create Compiler
            //Compiler = new GameCompiler(this);

            // Create Player Manager
            PlayerManager = new GraalPlayerList();

            // Connect to GServer
            GSConn = (IGameServer)new Connections.GraalServer();
            GSConn.RunServer();

            if (this.serverWindow.nickname != null && this.serverWindow.nickname != "")
                this.nickname = this.serverWindow.nickname;

            if (this.serverWindow.username != null && this.serverWindow.username != "")
                this.username = this.serverWindow.username;

            if (this.serverWindow.password != null && this.serverWindow.password != "")
                this.password = this.serverWindow.password;

            if (this.serverWindow.gserver != null && this.serverWindow.gserver != "")
                server = this.serverWindow.gserver;

            if (this.serverWindow.gport != null && this.serverWindow.gport != 0)
                this.port = this.serverWindow.gport;

            //GSConn.Disconnect();
            if (!GSConn.Connected)
            {
                this.form.WriteText("Not connected, connecting...");
                this.form.WriteText("Address:\t" + this.server);
                this.form.WriteText("Port:\t\t" + this.port.ToString());
                GSConn.Connect(this.server, this.port);

            }
            else
                this.form.WriteText("Already connected!");

            if (GSConn.Connected)
            {
                GSConn.SendLogin(this.username, this.password, this.nickname);
            }
        }
        /// <summary>
        /// Handle Received Data
        /// </summary>
        /// 
        protected override void HandleData(CString Packet)
        {
            if (this.serverWindow == null)
                this.serverWindow = ServerWindow.GetInstance();

            int prevPacket = 0;
            uint readc = 0;

            //System.Console.WriteLine("Test: " + Packet.Text);

            while (Packet.BytesLeft > 0)
            {
                CString CurPacket;
                // Grab Single Packet
                if (prevPacket == 100)
                    CurPacket = Packet.ReadChars2(readc);
                else
                    CurPacket = Packet.ReadString('\n');

                // Read Packet Type
                int PacketId = CurPacket.ReadGUByte1();

                // Call Packet Callback
                //RemoteControl.CallCallBack(PacketId, (CString)CurPacket.DeepClone());

                // Run Internal Packet Function
                switch ((PacketIn)PacketId)
                {
                    case PacketIn.LEVELCHEST:
                        {
                            CString Message = CurPacket.ReadString();

                            this.serverWindow.ErrorMsg = Message.Text.ToString();

                            //this.errorWindow.error_label.Text = Message.Text.ToString();

                            break;
                        }

                    case PacketIn.LEVELBOARD:
                        int serverCount = CurPacket.ReadGUByte1();
                        this.serverWindow.Write_Text("Number of servers: " + serverCount.ToString());
                        this.serverList.Clear();
                        this.listStore.Clear();
                        for (int i = 0; i < serverCount; i++)
                        {
                            // empty byte
                            CurPacket.ReadGUByte1();

                            // add server
                            TServer server = this.serverList.AddTServer((short)i);

                            // parse server
                            server.setName(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                            server.setLanguage(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                            server.setDescription(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                            server.setUrl(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                            server.setVersion(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                            server.setPCount(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                            server.setIp(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                            int port;
                            int.TryParse(CurPacket.ReadChars(CurPacket.ReadGUByte1()), out port);
                            server.setPort(port);

                            Gdk.Pixbuf icon;

                            if (server.getType() == "1")
                                icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_nuclear.png");
                            else if (server.getType() == "2")
                                icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_gold.png");
                            else if (server.getType() == "3")
                                icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_silver.png");
                            else if (server.getType() == "4")
                                icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_bronze.png");
                            else if (server.getType() == "5")
                                icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_uc.png");
                            else
                                icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_uc.png");

                            ServerWindow sw = ServerWindow.GetInstance();
                            this.listStore.AppendValues(icon, server.name, server.getPCount());

                        }
                        break;
                    default:
                        this.serverWindow.Write_Text("[" + Enum.GetName(typeof(PacketIn), PacketId).ToString() + "]: " + CurPacket.ReadString().Text + "\r\n");

                        break;
                }

                prevPacket = PacketId;

            }
            //if (this.serverWindow.ErrorMsg != "error")
            //	this.serverWindow.Hide();
        }
        /// <summary>
        /// Handle Received Data
        /// </summary>
        ///
        protected override void HandleData(CString Packet)
        {
            if (this.serverWindow == null)
            {
                this.serverWindow = ServerWindow.GetInstance();
            }

            int  prevPacket = 0;
            uint readc      = 0;

            //System.Console.WriteLine("Test: " + Packet.Text);

            while (Packet.BytesLeft > 0)
            {
                CString CurPacket;
                // Grab Single Packet
                if (prevPacket == 100)
                {
                    CurPacket = Packet.ReadChars2(readc);
                }
                else
                {
                    CurPacket = Packet.ReadString('\n');
                }


                // Read Packet Type
                int PacketId = CurPacket.ReadGUByte1();

                // Call Packet Callback
                //RemoteControl.CallCallBack(PacketId, (CString)CurPacket.DeepClone());

                Console.WriteLine("ServerLister Packet Received: " + (PacketIn)PacketId);

                // Run Internal Packet Function
                switch ((PacketIn)PacketId)
                {
                case PacketIn.INCORRPASS:
                {
                    CString Message = CurPacket.ReadString();

                    this.serverWindow.ErrorMsg = Message.Text.ToString();
                    this.loginWindow.Show();
                    ErrorWindow.GetInstance().SetTextAndShow(this.serverWindow.ErrorMsg);
                    this.serverWindow.Destroy();

                    break;
                }

                case PacketIn.LEVELBOARD:
                    int serverCount = CurPacket.ReadGUByte1();
                    this.serverWindow.Write_Text("Number of servers: " + serverCount.ToString());
                    this.serverList.Clear();
                    this.listStore.Clear();
                    for (int i = 0; i < serverCount; i++)
                    {
                        // empty byte
                        CurPacket.ReadGUByte1();

                        // add server
                        TServer server = this.serverList.AddTServer((short)i);

                        // parse server
                        server.setName(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setLanguage(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setDescription(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setUrl(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setVersion(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setPCount(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setIp(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        int port;
                        int.TryParse(CurPacket.ReadChars(CurPacket.ReadGUByte1()), out port);
                        server.setPort(port);

                        Gdk.Pixbuf icon;

                        if (server.getType() == "1")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_nuclear.png");
                        }
                        else if (server.getType() == "2")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_gold.png");
                        }
                        else if (server.getType() == "3")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_silver.png");
                        }
                        else if (server.getType() == "4")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_bronze.png");
                        }
                        else if (server.getType() == "5")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_uc.png");
                        }
                        else
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_uc.png");
                        }

                        ServerWindow sw = ServerWindow.GetInstance();
                        this.listStore.AppendValues(icon, server.name, server.getPCount());
                    }
                    break;

                default:
                    this.serverWindow.Write_Text("[" + Enum.GetName(typeof(PacketIn), PacketId).ToString() + "]: " + CurPacket.ReadString().Text + "\r\n");

                    break;
                }

                prevPacket = PacketId;
            }
            //if (this.serverWindow.ErrorMsg != "error")
            //	this.serverWindow.Hide();
        }
Example #11
0
        /*
         * /// <summary>
         * /// Accept incoming connection for NPC-Control
         * /// </summary>
         * /// <param name="ar"></param>
         * protected void NCControl_Accept(IAsyncResult ar)
         * {
         *      // Accept Socket
         *      NCConnection Client = new NCConnection(this, (Socket)NCListen.EndAcceptSocket(ar));
         *      Client.ReceiveData();
         *      NCList.Add(Client);
         *
         *      // Listen for incoming connections
         *      NCListen.BeginAcceptSocket(cNCAccept, NCListen);
         * }
         */
        /// <summary>
        /// Run NPC Server
        /// </summary>
        public void RunServer()
        {
            // Run Timeouts

            /*
             * foreach (KeyValuePair<String, ServerWeapon> wep in WeaponList)
             * {
             *      ScriptObj obj = (ScriptObj)wep.Value.ScriptObject;
             *      if (obj != null)
             *              obj.RunEvents();
             * }
             *
             * // Level-Npcs
             * lock (TimerLock)
             * {
             *      foreach (KeyValuePair<String, GraalLevel> lvl in LevelList)
             *      {
             *              foreach (KeyValuePair<int, GraalLevelNPC> npc in lvl.Value.NpcList)
             *              {
             *                      ScriptObj obj = (ScriptObj)npc.Value.ScriptObject;
             *                      if (obj != null)
             *                              obj.RunEvents();
             *              }
             *      }
             * }
             *
             * while (Compiler.RunList.Count > 0)
             * {
             *      IRefObject obj;
             *      lock (Compiler.RunList)
             *              obj = Compiler.RunList.Dequeue();
             *      obj.Call("onCreated", null);
             * }
             */
            this.form = Abstraction.GetInstance();

            this.form.Activate();
            this.form.WriteText("--- OpenGraal Instant Messenger / Remote Control ---");
            this.serverWindow = ServerWindow.GetInstance();
            // Default PM
            this.NCMsg = CString.tokenize("I am the Framework for\nthis game server. Almost\nall npc actions are controled\nby me.");

            // Create Compiler
            //Compiler = new GameCompiler(this);

            // Create Player Manager
            //PlayerManager = new GraalPlayerList();

            // Connect to GServer
            GSConn = new Connections.GraalServer();
            NCConn = new NCConnection();

            GSConn.RunServer();

            if (this.serverWindow.nickname != null && this.serverWindow.nickname != "")
            {
                this.nickname = this.serverWindow.nickname;
            }

            if (this.serverWindow.username != null && this.serverWindow.username != "")
            {
                this.username = this.serverWindow.username;
            }

            if (this.serverWindow.password != null && this.serverWindow.password != "")
            {
                this.password = this.serverWindow.password;
            }

            if (this.serverWindow.gserver != null && this.serverWindow.gserver != "")
            {
                server = this.serverWindow.gserver;
            }

            if (this.serverWindow.gport != null && this.serverWindow.gport != 0)
            {
                this.port = this.serverWindow.gport;
            }

            //GSConn.Disconnect();
            if (!GSConn.Connected)
            {
                this.form.WriteText("Not connected, connecting...");
                this.form.WriteText("Address:\t" + this.server);
                this.form.WriteText("Port:\t\t" + this.port.ToString());
                GSConn.Connect(this.server, this.port);
            }
            else
            {
                this.form.WriteText("Already connected!");
            }

            if (GSConn.Connected)
            {
                GSConn.SendLogin(this.username, this.password, this.nickname);
            }
        }
		public void InitNcConnection(CString ncip, CString ncport)
		{
			
			this.form = Abstraction.GetInstance();
			this.serverWindow = ServerWindow.GetInstance();
			
			// Connect to GServer
			
			//NCConn.RunServer();

			//GSConn.Disconnect();
			if (!NCConn.Connected)
			{
				this.form.WriteText("Connecting to NpcServer...");
				this.form.WriteText("Address:\t" + ncip.Text);
				this.form.WriteText("Port:\t\t" + ncport.ToString());
				NCConn.Connect(ncip.Text, ncport.ToInt());

			}
			else
				this.form.WriteText("Already connected!");

			if (NCConn.Connected)
			{
				this.form.WriteText("Connected!");
				NCConn.SendLogin(this.username, this.password);
			}
		}