Esempio n. 1
0
        public void _Conn()
        {
            CleanupConnection();
            var server = NewTcpListener();

            using (NetworkConnection conn = new NetworkConnection())
            {
                conn.Connect(localAddress, localPort);
                bool bbb = conn.Socket.Connected;
                var  sss = server.AcceptSocket();
                //conn.Socket.Disconnect(false);
                //conn.Socket.Close();
                conn.Socket.Dispose();
                //conn.Socket.BeginDisconnect(true, (o) =>
                //{
                //   Socket obj = (System.Net.Sockets.Socket)o.AsyncState;
                //    var ccccc = sss;
                //    bbb = conn.Socket.Connected;

                //}, sss);
                System.Threading.Thread.Sleep(100);

                bbb = conn.Socket.Connected;
            }
            server.Stop();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string ip            = "192.10.22.233";
            string serverPath    = @"\\" + ip + "\\IPC$";
            string loginUser     = "******";
            string loginPassword = "******";

            Console.WriteLine("[+] IP Address: {0}", ip);
            int status = NetworkConnection.Connect(serverPath, null, loginUser, loginPassword);

            if (status == (int)ERROR_ID.ERROR_SUCCESS)
            {
                List <string> users = GetAllUsersOfSystem(ip);
                foreach (string user in users)
                {
                    Console.WriteLine("    [>]: " + user);
                }
            }
            else
            {
                // 连接失败
                Console.WriteLine("  [-] Connection Error:{0}", status);
            }
            // 断开连接
            NetworkConnection.Disconnect(serverPath);
        }
Esempio n. 3
0
    private void Start()
    {
        Debug.Log("EXECUTE START");

        clientConn.Connect("127.0.0.1", 3456);
        DontDestroyOnLoad(this);
    }
Esempio n. 4
0
        public IEnumerator _ConnectExtra()
        {
            CleanupConnection();
            using (var server = NewSocketListener())
            {
                using (NetworkConnection conn = new NetworkConnection())
                {
                    conn.Connect(localAddress, localPort, new StringMessage("Text"));

                    foreach (var o in Wait())
                    {
                        yield return(null);
                    }
                    var    s1         = server.Accept();
                    string serverData = null;
                    using (var serverConn = new NetworkConnection(null, s1, true))
                    {
                        serverConn.Connected += (o, netMsg) =>
                        {
                            var msg = netMsg.ReadMessage <StringMessage>();
                            serverData = msg.Value;
                        };
                        foreach (var o in Wait())
                        {
                            yield return(null);
                        }
                    }

                    Assert.AreEqual(serverData, "Text");
                }
            }
        }
Esempio n. 5
0
 public void Connect()
 {
     _networkConnection.Connect();
     //_socket.Connect(IPAddress.Parse("127.0.0.1"), 8080);
     //_sendState.socket = _socket;
     //_recvState.socket = _socket;
 }
Esempio n. 6
0
 public async void Connect()
 {
     gameStatus = GameStatus.Connecting;
     uiManager.ShowConnecting();
     playerName   = uiManager.GetPlayerName();
     gameState.id = playerName;
     await connection.Connect();
 }
 public bool IsValidConnection()
 {
     using (var network = new NetworkConnection($"{networkPath}", networkCredential))
     {
         var result = network.Connect();
         return(result == 0);
     }
 }
Esempio n. 8
0
        public static void Initialize()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            InternalInstance = new ServerMain();
            InternalInstance.WriteConsoleLogo();

            EngineLog.Write(EngineLogLevel.Startup, "Starting WorldManagerServer");

            // Configuration
            if (!NetworkConfiguration.Initialize(out var netConfigMsg))
            {
                throw new StartupException(netConfigMsg);
            }
            NetConfig = NetworkConfiguration.Instance;

            if (!DatabaseConfiguration.Initialize(out var dbConfigMsg))
            {
                throw new StartupException(dbConfigMsg);
            }
            DbConfig = DatabaseConfiguration.Instance;

            if (!WorldConfiguration.Initialize(out var loginConfigMsg))
            {
                throw new StartupException(loginConfigMsg);
            }
            WorldConfig = WorldConfiguration.Instance;

            // Database
            if (!DB.AddManager(DatabaseType.Character, DatabaseConfiguration.Instance))
            {
                throw new StartupException("Database connection failure! See above error.");
            }

            // Handlers
            StoreHandlers();

            // Networking
            LoginServer.Connect(NetConfig.LoginNetConfig.S2SListenIP, (ushort)NetConfig.LoginNetConfig.S2SListenPort);
            ZoneServer.Listen(NetConfig.WorldNetConfig.S2SListenIP, (ushort)NetConfig.WorldNetConfig.S2SListenPort);
            ClientServer.Listen(NetConfig.WorldNetConfig.ListenIP, (ushort)NetConfig.WorldNetConfig.ListenPort);
            // TODO: GameLogServer
            // GameLogServer.Connect(NetConfig.GameLogNetConfig.S2SListenIP, (ushort)NetConfig.GameLogNetConfig.S2SListenPort);

            // Main server loop
            new Thread(() =>
            {
                while (true)
                {
                    Update(Time.Milliseconds);
                    Thread.Sleep(10);
                }
            }).Start();

            // Console commands?
        }
Esempio n. 9
0
        /// <summary>
        /// Prepare self a server and reach an outside server using Network Connection
        /// </summary>
        public void Connect()
        {
            string inOutIp     = Properties.Settings.Default.FlightServerIP;
            int    sendPort    = Properties.Settings.Default.FlightCommandPort;
            int    receivePort = Properties.Settings.Default.FlightInfoPort;

            if (inOutIp == personalIp)
            {
                inOutIp = localHost;
            }
            myTelnet.Connect(inOutIp, receivePort, sendPort);
        }
Esempio n. 10
0
 public void OnBtnConnectClicked()
 {
     if (hostData != null && networkConnection != null)
     {
         string TEMP_IP = "";
         foreach (string part in hostData.ip)
         {
             TEMP_IP = TEMP_IP + part;
         }
         networkConnection.connectToIP = TEMP_IP;
         networkConnection.connectPort = int.Parse(hostData.port.ToString());
         networkConnection.Connect();
     }
 }
Esempio n. 11
0
        private void Connect(string ip)
        {
            Disconnect();

            this.Cursor = Cursors.WaitCursor;
            try
            {
                m_networkConnection.Connect(ip, 23481);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error connecting");
            }
            this.Cursor = Cursors.Default;
        }
 public void CreateFile(string targetFile, string content)
 {
     using (var network = new NetworkConnection(networkPath, networkCredential))
     {
         network.Connect();
         var file = Path.Combine(this.networkPath, targetFile);
         if (!File.Exists(file))
         {
             using (File.Create(file)) { };
             using (StreamWriter sw = File.CreateText(file))
             {
                 sw.WriteLine(content);
             }
         }
     }
 }
Esempio n. 13
0
        /// <summary>
        /// バックアップ起動
        /// </summary>
        public void Start()
        {
            string serverFolderPath = @"\\" + _ipaddress + @"\" + _rootdirectory.TrimStart('\\');

            try
            {
                //接続テスト
                bool result      = true;
                int  connectTime = 0;
                while (result)
                {
                    int status = NetworkConnection.Connect(serverFolderPath, _localpath, _loginuser, _loginpassword);
                    if (status == (int)ERROR_ID.ERROR_SUCCESS)
                    {
                        result      = false;
                        connectTime = 0;
                        //copy
                        if (_copyinit == 0)
                        {
                            CopyDirectory _Info = new CopyDirectory(_localpath, _copydir);
                            _Info.MyCopyEnd += new CopyDirectory.CopyEnd(_Info_MyCopyEnd);
                            _Info.StarCopy();
                        }
                        if (InitWatcher())
                        {
                            // Begin watching.
                            fsw.EnableRaisingEvents = true;
                        }
                    }
                    else
                    {
                        if (connectTime > 20)
                        {
                            NetworkConnection.Disconnect(_localpath);
                            logger.Info("[" + _ipaddress + "]は接続できません");
                            result = false;
                        }
                        connectTime++;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
Esempio n. 14
0
        static OfficeHelper()
        {
            //增加的连接判断,支持\\方式
            var path = AppConfig.GetAppSettings("CacheViewFilePath");

            if (path.StartsWith("\\"))
            {
                string localpath     = AppConfig.GetAppSettings("SmbDriver") ?? "X:";
                string serverPath    = path.TrimEnd('\\');
                string loginUser     = AppConfig.GetAppSettings("SmbUserName");
                string loginPassword = AppConfig.GetAppSettings("SmbPassword");

                int status = NetworkConnection.Connect(serverPath, localpath, loginUser, loginPassword);
                if (status != (int)ERROR_ID.ERROR_SUCCESS)
                {
                    // 连接失败
                    Console.WriteLine(status);
                }
            }
        }
Esempio n. 15
0
            //调用方式:

            public static bool TestNetWorkConnection(string remotePath, string localPath, string username, string password)
            {
                int status = NetworkConnection.Connect(remotePath, localPath, username, password);

                if (status == (int)ERROR_ID.ERROR_SUCCESS)
                {
                    //System.Diagnostics.Process.Start(@"X:\123.TXT");
                    //System.Diagnostics.Process pExecuteEXE = new System.Diagnostics.Process();
                    //pExecuteEXE.StartInfo.FileName = @"X:\123.TXT";
                    //pExecuteEXE.StartInfo.Arguments = "'paramstr1 paramstr2,paramstr3'";
                    //pExecuteEXE.Start();
                    //pExecuteEXE.WaitForExit();
                }
                else
                {
                    MessageBox.Show(Enum.GetName(typeof(ERROR_ID), status));
                    return(false);
                }
                NetworkConnection.Disconnect(localPath);
                return(true);
            }
Esempio n. 16
0
        public void Start()
        {
            Logger.Current = LogLevel.Developer;
            _connection.LogMessageReceived += (level, s) =>
            {
                Console.WriteLine("[{0}] {1}", level, s);
            };

            _connection.Configure(_config);
            _connection.ResponseReceived += OnResponseReceived;
            _connection.StatusChanged    += OnStatusChanged;


            IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 5056);

            _connection.Connect(remoteEndPoint, new Version(0, 1, 0), null);

            Thread receiveThread = new Thread(Receive);

            receiveThread.Start();
        }
Esempio n. 17
0
    // Start is called before the first frame update
    async void Start()
    {
        RealmState initialState = await NetworkConnection.GetStateAsync();

        RealmStateManager.UpdateState(initialState);
        MapManager.InitMap(initialState.map);

        await NetworkConnection.Connect();

        while (NetworkConnection.IsOpen())
        {
            string message = await NetworkConnection.Receive();

            if (!string.IsNullOrEmpty(message))
            {
                try {
                    NetworkMessage <RealmEventBase> networkMessage = NetworkMessageFactory.GetNetworkMessage(message);
                    if (networkMessage != null && networkMessage.realmEvent != null && !string.IsNullOrEmpty(networkMessage.realmEventType))
                    {
                        // Re-parse with the appropriate event type. This is ugly.
                        Type eventType          = RealmEventRegistry.GetEventDataType(networkMessage.realmEventType);
                        Type networkMessageType = typeof(NetworkMessage <>).MakeGenericType(eventType);

                        object genericMessage = NetworkMessageFactory.GetNetworkMessage(message, networkMessageType);
                        object realmEvent     = networkMessageType.GetField("realmEvent").GetValue(genericMessage);

                        RealmStateManager.UpdateState(networkMessage.realmStateFragment);

                        // TODO: Fire off this event and continue. Don't wait for a result.
                        EventManager.TriggerEvent(networkMessage.realmEventType, realmEvent as RealmEventBase);
                        //RealmStateManager.UpdateState(networkMessage.realmStateFragment);
                    }
                } catch (Exception e) {
                    Debug.Log("Exception in NetworkHandler: " + e.Message);
                    Debug.Log(e.StackTrace);
                }
            }
        }
    }
Esempio n. 18
0
        /// <summary>
        /// IP接続
        /// </summary>
        private bool ObjectConnect(string MonitorSrcPath, string MonitorRootDirectory, string MonitorUser, string MonitorPassword)
        {
            bool connectResult = false;

            try
            {
                //接続テスト
                bool result      = true;
                int  connectTime = 0;
                while (result)
                {
                    int status = NetworkConnection.Connect(paraMonitorSrcPath, paraMonitorRootDirectory, paraMonitorUser, paraMonitorPassword);
                    if (status == (int)ERROR_ID.ERROR_SUCCESS)
                    {
                        result        = false;
                        connectTime   = 0;
                        connectResult = true;
                    }
                    else
                    {
                        if (connectTime > 20)
                        {
                            NetworkConnection.Disconnect(paraMonitorSrcPath);
                            logger.Info("[" + paraMonitorIP + "]は接続できません");
                            result = false;
                        }
                        connectTime++;
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
            return(connectResult);
        }
 private void Start()
 {
     m_Connection = GetComponent<NetworkConnection>();
     m_Connection.Connect();
 }
Esempio n. 20
0
 public Task Connect(IPEndPoint endpoint)
 {
     return(_connection.Connect(endpoint));
 }
Esempio n. 21
0
        private IEnumerator _Event_Connected()
        {
            CleanupConnection();

            using (var server = NewSocketListener())
            {
                bool isClientConnected = false, isClientDisconnected = false;
                bool isServerConnected = false, isServerDisconnected = false;
                using (NetworkConnection conn = new NetworkConnection())
                {
                    conn.Connected += (o, netMsg) =>
                    {
                        isClientConnected = true;
                    };
                    conn.Disconnected += (o) =>
                    {
                        isClientDisconnected = true;
                    };
                    conn.Connect(localAddress, localPort);

                    foreach (var o in Wait())
                    {
                        yield return(null);
                    }

                    var s1 = server.Accept();
                    Assert.IsNotNull(s1);

                    using (var serverConn = new NetworkConnection(null, s1, true))
                    {
                        serverConn.Connected += (o, netMsg) =>
                        {
                            isServerConnected = true;
                        };
                        serverConn.Disconnected += (o) =>
                        {
                            isServerDisconnected = true;
                        };
                        foreach (var o in Wait())
                        {
                            yield return(null);
                        }
                        Assert.IsTrue(isClientConnected);
                        Assert.IsFalse(isClientDisconnected);
                        Assert.IsTrue(isServerConnected);
                        Assert.IsFalse(isServerDisconnected);


                        isClientConnected    = false;
                        isClientDisconnected = false;
                        isServerConnected    = false;
                        isServerDisconnected = false;
                    }
                    foreach (var o in Wait())
                    {
                        yield return(null);
                    }
                }
                Assert.IsFalse(isClientConnected);
                Assert.IsTrue(isClientDisconnected);
                Assert.IsFalse(isServerConnected);
                Assert.IsTrue(isServerDisconnected);
            }
        }
Esempio n. 22
0
 public void OnBtnConnectClicked()
 {
     networkConnection.connectToIP = inputIP.text;
     networkConnection.connectPort = int.Parse(inputPort.text);
     networkConnection.Connect();
 }
 private void Start()
 {
     GameObject go = GameObject.FindGameObjectWithTag("Network");
     m_Connection = go.GetComponent<NetworkConnection>();
     m_Connection.Connect();
 }
Esempio n. 24
0
        public ContentResult SubmitVideo(HttpPostedFileBase FileData, string folder, string videoName)
        {
            string filename   = "";
            string resultName = "";

            if (null != FileData)
            {
                try
                {
                    filename = Path.GetFileName(FileData.FileName); //获得文件名
                    string fullPathname = Path.Combine(folder, filename);
                    //文件后缀名
                    string suffix = FileData.FileName.Substring(FileData.FileName.LastIndexOf(".") + 1).ToLower();
                    resultName = Guid.NewGuid() + "." + suffix;
                    if (saveFile(FileData, folder, resultName))
                    {
                        //解压操作  然后获得解压后的文件名 保存在数据库中
                        int i = resultName.LastIndexOf(".");

                        GzipHelper.UnZip(UFCOVideoADDR, UFCOVideoZIP,
                                         UFCOVideoUSR, UFCOVideoPwd,
                                         HttpContext.Server.MapPath(folder + resultName),
                                         UFCOVideoZIP + @"\" + resultName.Substring(0, i), "", true);
                        Cl_VideoManage model = new Cl_VideoManage()
                        {
                            LastUpdateTime = DateTime.Now,
                            Name           = videoName.Replace("%2B", "+"),                 //.Replace("%3C","<").Replace("%3E",">").Replace("%2F","/"),
                            Path           =
                                resultName.Substring(0, i) +
                                @"/Untitled/Untitled_media/Untitled.wmv",
                            Size     = FileData.ContentLength / 1024,
                            IsDelete = 0
                        };
                        int status = NetworkConnection.Connect(UFCOVideoADDR, UFCOVideoZIP,
                                                               string.Format(@"{0}", UFCOVideoUSR), UFCOVideoPwd);
                        if (status == (int)ERROR_ID.ERROR_SUCCESS || status == 1202)
                        {
                            string aa =
                                ProcessRequest(UFCOVideoZIP + resultName.Substring(0, i) + @"/Untitled/Untitled.html");

                            var lefttop = getmodelList(aa, "<div id=\"indexlinks\" (.+?)></div>", 1);
                            var leftbot = getmodelList(aa,
                                                       "<table width=\"202\" height=\"200\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-bottom:1px solid #669966\">(.+?)</table>",
                                                       1);
                            model.BottomContent = "";
                            model.TopContent    = "";

                            if (lefttop.Count != 0)
                            {
                                model.LeftContent = lefttop[0].ToString();
                            }
                            else
                            {
                                model.LeftContent = "";
                            }
                            if (leftbot.Count != 0)
                            {
                                model.RightContent = leftbot[0].ToString();
                            }
                            else
                            {
                                model.RightContent = "";
                            }
                            _videoManageBL.Add(model);
                        }
                        NetworkConnection.Disconnect(UFCOVideoZIP);
                        return(Content(model.Id.ToString() + status.ToString()));
                    }
                    else
                    {
                        return(Content("-1"));
                    }
                }
                catch (Exception ex)
                {
                    return(Content(ex.Message + "--------" + ex.Source + "-----------" + ex.StackTrace));
                }
            }
            return(Content("-1"));
        }
Esempio n. 25
0
    // 进入比赛房间
    void FindGame()
    {
        GUILayout.BeginArea(new Rect(Screen.width / 2 - 300, Screen.height / 2 - 200, 600, 400));
        GUI.Box(new Rect(0, 20, 600, 400), "");
        GUILayout.Label("Find Game Servers");

        GUILayout.BeginArea(new Rect(0, 30, 595, 200));
        GUI.Box(new Rect(5, 0, 590, 200), "", GUI.skin.FindStyle("Box"));
        scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(575), GUILayout.Height(200));
        if (UtilsC.IsHostsExists())
        {
            foreach (HostData element in networkConnection.hostData)
            {
                string name        = " [" + element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit + "] ";
                string hostInfo    = "";
                string gameComment = " [" + element.comment + "] ";

                foreach (string host in element.ip)
                {
                    hostInfo = hostInfo + host + ":" + element.port + " ";
                }
                hostInfo = " [" + hostInfo + "] ";

                GUILayout.BeginHorizontal();
                GUILayout.Label(name + gameComment + hostInfo + (element.passwordProtected ? "Private " : "Public ").ToString(), GUI.skin.FindStyle("Lable1"));
                GUILayout.Space(100);
                if (GUILayout.Button("Connect", GUI.skin.FindStyle("Button"), GUILayout.MaxWidth(55)))
                {
                    string TEMP_IP = "";
                    foreach (string part in element.ip)
                    {
                        TEMP_IP = TEMP_IP + part;
                    }
                    networkConnection.connectToIP = TEMP_IP;
                    networkConnection.connectPort = int.Parse(element.port.ToString());
                    networkConnection.Connect();
                }
                GUILayout.Space(10);
                GUILayout.EndHorizontal();
            }
        }
        else
        {
            GUILayout.Label(" There are no hosts registered");
        }
        GUILayout.EndScrollView();
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(0, 233, 480, 127));
        GUI.Box(new Rect(5, 0, 450, 127), "", GUI.skin.FindStyle("Box"));
        GUILayout.BeginArea(new Rect(15, 5, 350, 250));
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();
        GUILayout.Label("IP: ");
        GUILayout.Label("Port: ");
        GUILayout.EndVertical();
        GUILayout.BeginVertical();
        networkConnection.connectToIP = GUILayout.TextField(networkConnection.connectToIP, GUILayout.MaxWidth(200));
        networkConnection.connectPort = int.Parse(GUILayout.TextField(networkConnection.connectPort.ToString(), GUILayout.MaxWidth(200)));
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        networkConnection.usePassword = GUILayout.Toggle(networkConnection.usePassword, "Use Password");
        if (networkConnection.usePassword)
        {
            networkConnection.password = GUILayout.PasswordField(networkConnection.password, "*"[0], 15, GUILayout.Width(100));
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(15, 340, 250, 30));
        if (GUILayout.Button("Connect", GUI.skin.FindStyle("Button"), GUILayout.MaxWidth(130)))
        {
            networkConnection.Connect();
        }
        GUILayout.EndArea();

        GUILayout.BeginArea(new Rect(5, 365, 500, 30));
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Refresh List", GUILayout.MaxWidth(130)))
        {
            networkConnection.RefreshServerList();
        }
        if (GUILayout.Button("Back To Menu", GUILayout.MaxWidth(130)))
        {
            menuState = "menublock";
        }
        GUILayout.EndHorizontal();
        GUILayout.EndArea();
        GUILayout.EndArea();
    }