Make sending packet events possible

This commit is contained in:
K35 2022-01-10 14:08:38 +00:00
parent 48a0713045
commit 8419ecdd09
3 changed files with 6 additions and 5 deletions

View File

@ -46,7 +46,7 @@ class CopyTransportS2 : Example.JRpcTransport {
public override Task Write(string data) { public override Task Write(string data) {
Console.WriteLine("--> " + data); Console.WriteLine("--> " + data);
this.tr1.DevSendPacket(data); this.tr1.SendPacketEvent(data);
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -63,7 +63,7 @@ class CopyTransportS1 : Example.JRpcTransport {
public override Task Write(string data) { public override Task Write(string data) {
Console.WriteLine("<-- " + data); Console.WriteLine("<-- " + data);
this.tr2.DevSendPacket(data); this.tr2.SendPacketEvent(data);
return Task.CompletedTask; return Task.CompletedTask;
} }
} }
@ -77,8 +77,8 @@ class Program {
var server = new Example.JRpcServer<int>(); var server = new Example.JRpcServer<int>();
server.AddService(new TestSrvimpl()); server.AddService(new TestSrvimpl());
var transport = new CopyTransportS1(); var transport = new CopyTransportS1();
var sess = server.GetSession(transport, 0); var sess = server.GetSession(transport, 0);
var client = new Example.JRpcClient(transport.tr2); var client = new Example.JRpcClient(transport.tr2);
var testService = new Example.TestServiceClient(client); var testService = new Example.TestServiceClient(client);

View File

@ -1,6 +1,6 @@
{ {
"name": "@hibas123/jrpcgen", "name": "@hibas123/jrpcgen",
"version": "1.0.16", "version": "1.0.18",
"main": "lib/index.js", "main": "lib/index.js",
"license": "MIT", "license": "MIT",
"packageManager": "yarn@3.1.1", "packageManager": "yarn@3.1.1",

View File

@ -8,7 +8,8 @@ public abstract class JRpcTransport {
public event NotifyPacket OnPacket; public event NotifyPacket OnPacket;
public abstract Task Write(string data); public abstract Task Write(string data);
public void DevSendPacket(string data) { // TODO: Spend some time finding a better permission, but it is fine for now
public void SendPacketEvent(string data) {
this.OnPacket.Invoke(data); this.OnPacket.Invoke(data);
} }
} }