public Protocol(IGateClient sc) { _client = sc; var loader = new ProtocolLoader(); _rpc = loader.CreateRpcProto(); }
public static void Init(int session, string secret) { _session = session; _secret = Encoding.UTF8.GetBytes(secret); var loader = new ProtocolLoader(); _rpc = loader.CreateBattleProto(); }
public void Run () { SpTypeManager server_tm = SpTypeManager.Import (server_proto); server = SpRpc.Create (server_tm, "package"); client = SpRpc.Create (client_proto, "package"); client.Attach (server_tm); TestFoobar (); TestFoo (); TestBar (); TestBlackhole (); }
public Protocol(IGateClient sc, Socket socket) { _client = sc; _transporter = new Transporter(socket, this) { onDisconnect = Disconnect }; _transporter.Start(); var loader = new ProtocolLoader(); _rpc = loader.CreateRpcProto(); }
public void Run() { SpTypeManager server_tm = SpTypeManager.Import(server_proto); server = SpRpc.Create(server_tm, "package"); client = SpRpc.Create(client_proto, "package"); client.Attach(server_tm); TestFoobar(); TestFoo(); TestBar(); TestBlackhole(); }
public void Run () { IPAddress ip = IPAddress.Parse ("127.0.0.1"); mSocket.Connect(new IPEndPoint(ip, 8888)); mRpc = SpRpc.Create (s2c, "package"); mRpc.Attach (c2s); Send ("handshake", null); Send ("set", new SpObject (SpObject.ArgType.Table, "what", "hello", "value", "world")); mSocket.BeginReceive (mRecvBuffer, 0, mRecvBuffer.Length, SocketFlags.None, new AsyncCallback(ReadCallback), this); }
public void Run() { IPAddress ip = IPAddress.Parse("127.0.0.1"); mSocket.Connect(new IPEndPoint(ip, 8888)); mRpc = SpRpc.Create(s2c, "package"); mRpc.Attach(c2s); Send("handshake", null); Send("set", new SpObject(SpObject.ArgType.Table, "what", "hello", "value", "world")); mSocket.BeginReceive(mRecvBuffer, 0, mRecvBuffer.Length, SocketFlags.None, new AsyncCallback(ReadCallback), this); }
public static SpRpc Create(SpTypeManager tm, string package) { if (tm == null) { return(null); } SpType t = tm.GetType(package); if (t == null) { return(null); } SpRpc rpc = new SpRpc(tm, t); return(rpc); }
private SpRpc CreateProto(string subDir) { SpTypeManager c2SMgr; SpTypeManager s2CMgr; var c2S = _path + subDir + "/c2s.sproto"; using (var stream = new FileStream(c2S, FileMode.Open)) { c2SMgr = SpTypeManager.Import(stream); } var s2C = _path + subDir + "/s2c.sproto"; using (var stream = new FileStream(s2C, FileMode.Open)) { s2CMgr = SpTypeManager.Import(stream); } var rpc = SpRpc.Create(s2CMgr, "package"); rpc.Attach(c2SMgr); return(rpc); }
public bool Start(string serverIP, short port, string packageName, string s2c, string c2s) { bool result = true; try { mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress ipAddress = IPAddress.Parse(serverIP); IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port); mSocket.ReceiveBufferSize = MAX_BUFFER_SIZE; mSocket.NoDelay = true; mSocket.BeginConnect(ipEndPoint, new AsyncCallback(ConnectCallback), mSocket); if (mConnTimeoutEvent.WaitOne(MAX_CONNECT_TIME, false)) { if (mSocket.Connected) { mRpc = SpRpc.Create(s2c, packageName); mRpc.Attach(c2s); mSocket.BeginReceive(mReceiveBuffer, 0, mReceiveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), this); } } else { // Block time out and do not recevie any signal DebugHelper.Log("Block time out and do not recevie any signal"); } } catch (Exception ex) { DebugHelper.Log(ex.ToString()); result = false; } return(result); }
public bool Start(string serverIP, short port, string packageName, string s2c, string c2s) { bool result = true; try { mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress ipAddress = IPAddress.Parse(serverIP); IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port); mSocket.ReceiveBufferSize = MAX_BUFFER_SIZE; mSocket.NoDelay = true; mSocket.BeginConnect(ipEndPoint, new AsyncCallback(ConnectCallback), mSocket); if (mConnTimeoutEvent.WaitOne(MAX_CONNECT_TIME, false)) { if (mSocket.Connected) { mRpc = SpRpc.Create(s2c, packageName); mRpc.Attach(c2s); mSocket.BeginReceive(mReceiveBuffer, 0, mReceiveBuffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), this); } } else { // Block time out and do not recevie any signal DebugHelper.Log("Block time out and do not recevie any signal"); } } catch(Exception ex) { DebugHelper.Log(ex.ToString()); result = false; } return result; }
public static SpRpc Create (SpTypeManager tm, string package) { if (tm == null) return null; SpType t = tm.GetType (package); if (t == null) return null; SpRpc rpc = new SpRpc (tm, t); return rpc; }
public void Run () { mRpc = SpRpc.Create (s2c, "package"); mRpc.Attach (c2s); Send ("handshake", null); Send ("set", new SpObject (SpObject.ArgType.Table, "what", "hello", "value", "world")); mSocket.BeginReceive (mRecvBuffer, 0, mRecvBuffer.Length, SocketFlags.None, new AsyncCallback(ReadCallback), this); }