public void Connect(string host, int port) { this.m_hostAddress = host; this.m_hostPort = port; this.Disconnect(); this.m_sslSocket = new SslSocket(); this.m_connectionState = SslClientConnection.ConnectionState.Connecting; try { this.m_sslSocket.BeginConnect(host, port, this.m_bundleSettings, new SslSocket.BeginConnectDelegate(this.ConnectCallback)); } catch (Exception exception1) { Exception exception = exception1; string str = string.Concat(this.m_hostAddress, ":", this.m_hostPort); LogAdapter.Log(LogLevel.Warning, string.Concat("Could not connect to ", str, " -- ", exception.Message)); this.m_connectionState = SslClientConnection.ConnectionState.ConnectionFailed; this.TriggerOnConnectHandler(BattleNetErrors.ERROR_RPC_PEER_UNKNOWN); } this.m_bundleSettings = null; }
private void ReceiveCallback(IAsyncResult ar) { try { if (this.m_socket != null && this.m_socket.get_Connected()) { int num = this.m_socket.EndReceive(ar); if (num > 0) { this.BytesReceived(num); this.m_socket.BeginReceive(this.m_receiveBuffer, 0, ClientConnection <PacketType> .RECEIVE_BUFFER_SIZE, 0, new AsyncCallback(this.ReceiveCallback), null); return; } } this.AddDisconnectEvent(BattleNetErrors.ERROR_RPC_PEER_DISCONNECTED); } catch (Exception ex) { LogAdapter.Log(LogLevel.Debug, ex.ToString()); this.AddDisconnectEvent(BattleNetErrors.ERROR_RPC_PEER_DISCONNECTED); } }
public bool Init(bool internalMode, string userEmailAddress, string targetServer, int port, SslParameters sslParams, ClientInterface ci) { if (this.m_initialized) { return(true); } if (ci == null) { return(false); } this.m_stopwatch.Reset(); this.m_stopwatch.Start(); this.m_clientInterface = ci; this.m_auroraEnvironment = targetServer; this.m_auroraPort = ((port > 0) ? port : 1119); this.m_userEmailAddress = userEmailAddress; bool flag = false; try { string text; flag = UriUtils.GetHostAddress(targetServer, out text); } catch (Exception ex) { this.m_logSource.LogError("Exception within GetHostAddress: " + ex.Message); } if (flag) { this.m_initialized = true; this.ConnectAurora(targetServer, this.m_auroraPort, sslParams); } else { LogAdapter.Log(LogLevel.Fatal, "GLOBAL_ERROR_NETWORK_NO_CONNECTION"); } return(this.m_initialized); }
private ClientRequest CreateClientRequest(int type, int sys, byte[] bs, ulong route) { ClientRequest clientRequest = new ClientRequest(); clientRequest.AddAttribute(ProtocolHelper.CreateAttribute("p", bs)); if (!BattleNet.IsVersionInt()) { clientRequest.AddAttribute(ProtocolHelper.CreateAttribute("v", BattleNet.GetVersion() + ((sys != 0) ? "b" : "c"))); } else { int num = 0; if (!int.TryParse(BattleNet.GetVersion(), out num)) { LogAdapter.Log(LogLevel.Error, "Could not convert BattleNetVersion to int: " + BattleNet.GetVersion()); } clientRequest.AddAttribute(ProtocolHelper.CreateAttribute("v", (long)(10 * num + sys))); } if (route != 0UL) { clientRequest.AddAttribute(ProtocolHelper.CreateAttribute("r", route)); } return(clientRequest); }
private void HandleEchoRequest(RPCContext context) { if (this.m_rpcConnection == null) { LogAdapter.Log(LogLevel.Error, "HandleEchoRequest with null RPC Connection"); return; } EchoRequest echoRequest = EchoRequest.ParseFrom(context.Payload); EchoResponse echoResponse = new EchoResponse(); if (echoRequest.HasTime) { echoResponse.SetTime(echoRequest.Time); } if (echoRequest.HasPayload) { echoResponse.SetPayload(echoRequest.Payload); } EchoResponse message = echoResponse; this.m_rpcConnection.QueueResponse(context, message); Console.WriteLine(string.Empty); Console.WriteLine("[*]send echo response"); }
public void ClearLogEvents() { LogAdapter.ClearLogEvents(); }
public List <string> GetLogEvents() { return(LogAdapter.GetLogEvents()); }
public void Print(LogLevel level, string message) { LogAdapter.Log(level, message); }