/// <summary> /// Connect the socket. /// </summary> public void Connect(ConnectionInformations connectionInformations) { //if (m_RawSocket != null && !m_RawSocket.Connected) // RawConnect(); m_MessageInformations = new MessageInformations(account); if (m_IsChangingServer) { client.Close("Changing server."); client = new NetClient(); this.client.Connected += new EventHandler <NetSocketConnectedEventArgs>(client_Connected); this.client.DataArrived += new EventHandler <NetSockDataArrivalEventArgs>(client_DataArrived); this.client.Disconnected += new EventHandler <NetSocketDisconnectedEventArgs>(client_Disconnected); this.client.ErrorReceived += new EventHandler <NetSockErrorReceivedEventArgs>(client_ErrorReceived); this.client.StateChanged += new EventHandler <NetSockStateChangedEventArgs>(client_StateChanged); } try { client.Connect(new IPEndPoint(IPAddress.Parse(connectionInformations.Address), connectionInformations.Port)); } catch (SocketException sockEx) { account.Log(new ErrorTextInformation("[Socket Exception] " + sockEx.Message), 0); account.TryReconnect(10); } }
public static void Test(ServerStatusEnum status, AccountUC account) { switch (status) { case ServerStatusEnum.Offline: account.Log(new ConnectionTextInformation("Echec de connexion : serveur déconnecté."), 0); account.TryReconnect(600); break; case ServerStatusEnum.Saving: account.Log(new ConnectionTextInformation("Echec de connexion : serveur en sauvegarde."), 0); account.TryReconnect(600); break; case ServerStatusEnum.Full: account.Log(new ConnectionTextInformation("Echec de connexion : serveur complet."), 0); account.TryReconnect(60); break; default: account.Log(new ConnectionTextInformation("Echec de connexion : raison inconnue."), 0); account.TryReconnect(30); break; } }
public static void Test(uint status, AccountUC account) { switch (status) { case m_Offline: account.Log(new ConnectionTextInformation("Echec de connexion : serveur déconnecté."), 0); account.TryReconnect(15); break; case m_Saving: account.Log(new ConnectionTextInformation("Echec de connexion : serveur en sauvegarde."), 0); account.TryReconnect(15); break; case m_Full: account.Log(new ConnectionTextInformation("Echec de connexion : serveur complet."), 0); account.TryReconnect(5); break; default: account.Log(new ConnectionTextInformation("Echec de connexion : raison inconnue."), 0); account.TryReconnect(5); break; } }
public static void Test(int reason, AccountUC account) { switch (reason) { case m_WrongCredentials: account.Log(new ErrorTextInformation("Echec de connexion : mauvais identifiants."), 0); break; case m_Banned: account.Log(new ErrorTextInformation("Echec de connexion : compte banni."), 0); break; case m_Kicked: account.Log(new ErrorTextInformation("Echec de connexion : compte banni temporairement."), 0); break; case m_InMaintenance: account.Log(new ErrorTextInformation("Echec de connexion : serveur en maintenance."), 0); account.TryReconnect(15); break; default: account.Log(new ErrorTextInformation("Echec de connexion : erreur inconnue."), 0); break; } }
public static void Test(IdentificationFailureReasonEnum reason, AccountUC account) { switch (reason) { case IdentificationFailureReasonEnum.WRONG_CREDENTIALS: account.Log(new ErrorTextInformation("Echec de connexion : mauvais identifiants."), 0); break; case IdentificationFailureReasonEnum.BANNED: account.Log(new ErrorTextInformation("Echec de connexion : compte banni."), 0); break; case IdentificationFailureReasonEnum.KICKED: account.Log(new ErrorTextInformation("Echec de connexion : compte banni temporairement."), 0); break; case IdentificationFailureReasonEnum.IN_MAINTENANCE: account.Log(new ErrorTextInformation("Echec de connexion : serveur en maintenance."), 0); account.TryReconnect(15); break; default: account.Log(new ErrorTextInformation("Echec de connexion : erreur inconnue."), 0); break; } }
public void Connect(ConnectionInformations connectionInformations) { //if (MainForm.ActualMainForm.IpAdressChoice.SelectedIndex > -1) //{ // IPEndPoint e = new IPEndPoint(new IPAddress(GetBytes(MainForm.ActualMainForm.IpAdressChoice.SelectedText)), 0); // m_Socket.Bind(e); //} if (m_RawSocket != null && !m_RawSocket.Connected) { RawConnect(); } if (m_IsChangingServer) { m_Socket.Disconnect(false); m_Socket.Dispose(); m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); account.SetStatus(Status.Disconnected); } try { m_Socket.Connect(connectionInformations.Address, connectionInformations.Port); if (m_Socket.Connected) { account.SetStatus(Status.None); account.LatencyFrame = new LatencyFrame(account); account.Log(new ConnectionTextInformation("Connexion établie au serveur " + connectionInformations.ServerName + "."), 0); if ((!m_IsChangingServer)) { m_ReceptionThread = new Thread(SocketReception); m_ReceptionThread.Start(); } m_IsChangingServer = false; } else { account.Log(new ConnectionTextInformation("Connexion échouée."), 0); } } catch (SocketException sockEx) { account.Log(new ErrorTextInformation("[Socket Exception] " + sockEx.Message), 0); account.TryReconnect(1); } }
public static void ServerListMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { ServersListMessage msg = new ServersListMessage(); using (BigEndianReader reader = new BigEndianReader(packetDatas)) { msg.Deserialize(reader); } account.Log(new ConnectionTextInformation("< --- Probably, your server is under maintenance --- >"), 0); msg.Servers.ForEach(server => account.Log(new ConnectionTextInformation("< --- Server : " + BlueSheep.Common.Data.I18N.GetText((int)GameData.GetDataObject(D2oFileEnum.Servers, server.ObjectID).Fields["nameId"]) + " Status : " + ((ServerStatusEnum)server.Status).Description() + " --- >"), 0)); //foreach (GameServerInformations gsi in msg.servers) //{ // account.Log(new ConnectionTextInformation("Server : "+ // IntelliSense.ServersList.Where(server => server.Id == gsi.id).FirstOrDefault().Name), 0); //} account.Log(new ConnectionTextInformation("Serveur complet."), 0); account.TryReconnect(600); }
public static void ServerListMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { account.Log(new ConnectionTextInformation("Serveur complet."), 0); account.TryReconnect(600); }
public static void CharacterSelectedErrorMessageTreatment(Message message, byte[] packetDatas, AccountUC account) { account.Log(new ConnectionTextInformation("Erreur lors de la sélection du personnage."), 0); account.TryReconnect(30); }