public void Handle(GetDirectCommand command) { Console.WriteLine("GetDirectCommand"); var bytes = this.SimpleDb.GetDirect(command.TableId, command.Key); if (this.From != null && bytes != null) { this.From.Tell(bytes); } }
private async static void GetDirect() { var server = AllPet.Pipeline.PipelineSystem.CreatePipelineSystemV1(new AllPet.Common.Logger()); server.OpenNetwork(new AllPet.peer.tcp.PeerOption()); server.RegistModule("me", new GetActor()); server.Start(); var remote = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 8888); //連接 var systemref = await server.ConnectAsync(remote); var actor = server.GetPipeline(null, "this/me"); GetDirectCommand command = new GetDirectCommand() { TableId = new byte[] { 0x03, 0x02, 0x03 }, Key = new byte[] { 0x10, 0x10 } }; var bytes = ProtocolFormatter.Serialize <GetDirectCommand>(Method.GetDirect, command); actor.Tell(bytes); //var actor = server.GetPipeline(null, "127.0.0.1:8888/get"); //{ // MemoryStream ms = new MemoryStream(); // GetDirectCommand command = new GetDirectCommand() // { // TableId = new byte[] { 0x02, 0x02, 0x03 }, // Key = new byte[] { 0x13, 0x13 } // }; // BinaryFormatter bf = new BinaryFormatter(); // bf.Serialize(ms, command); // actor.Tell(ms.ToArray()); //} server.CloseListen(); server.CloseNetwork(); server.Dispose(); }