Beispiel #1
0
        public static bool createAndConnectToLocalServer(string serverType, string level)
        {
            if (!createServer(serverType, level))
                return false;

            GameConnection conn = new ObjectCreator("GameConnection", "ServerConnection", t3d.sGlobal["$Pref::Server::Net::ClientGameConnectionModelClass"]).Create();

            ((SimGroup) "RootGroup").add(conn);

            conn.setConnectArgs(t3d.sGlobal["$pref::Player::Name"]);
            conn.setJoinPassword(t3d.sGlobal["$Client::Password"]);

            if (conn.connectLocal() != string.Empty)
                {
                conn.delete();
                destroyServer();
                return false;
                }
            return true;
        }
        //
        //----------------------------------------------------------------------------
        //Helper functions
        //----------------------------------------------------------------------------

        public static void connect(string server)
        {
            GameConnection conn = new ObjectCreator("ServerConnection").Create();
            ((SimGroup) "RootGroup").add(conn);
            conn.setConnectArgs(omni.sGlobal["$pref::Player::Name"]);
            conn.setJoinPassword(omni.sGlobal["$Client::Password"]);
            conn.connect(server);
        }
        public void join()
        {
            Util.cancelServerQuery();
            int index = ((GuiTextListCtrl) "JS_serverList").getSelectedId();
            // The server info index is stored in the row along with the
            // rest of displayed info.

            if (Util.setServerInfo((uint) index))
                {
                ((GuiCanvas) "Canvas").setContent("LoadingGui");
                ((GuiProgressBitmapCtrl) "LoadingProgress").setValue("1");
                ((GuiTextCtrl) "LoadingProgressTxt").setValue("WAITING FOR SERVER");
                ((GuiCanvas) "Canvas").repaint(-1);

                if ("ServerConnection".isObject())
                    "ServerConnection".delete();

                GameConnection conn = new ObjectCreator("GameConnection", "ServerConnection").Create();
                conn.setConnectArgs(sGlobal["$pref::Player::Name"]);
                conn.setJoinPassword(sGlobal["$Client::Password"]);
                conn.connect(sGlobal["$ServerInfo::Address"]);
                }
        }