-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestProcessor.cs
More file actions
75 lines (64 loc) · 1.92 KB
/
Copy pathTestProcessor.cs
File metadata and controls
75 lines (64 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using GoPlay.Core.Attributes;
using GoPlay.Core.Processors;
using GoPlay.Core.Protocols;
using GoPlay.Exceptions;
using GoPlay.Interfaces;
namespace Demo.Common;
[Processor("test")]
public class TestProcessor : ProcessorBase, IStart, IStop, IUpdate
{
private int m_count = -1;
public override string[] Pushes => new string[]
{
"test.push"
};
public string Prefix = "Test";
[Request("inc")]
public PbLong Inc(Header header, PbLong value)
{
return new PbLong
{
Value = value.Value + 1
};
}
[Request("echo")]
public PbString Echo(Header header, PbString str)
{
// Console.WriteLine($">>>> Server.Echo Recv: {str.Value}");
// Console.WriteLine(Server.SessionManager.Get<ReqHankShake>(header.ClientId, nameof(ReqHankShake)));
return new PbString
{
Value = $"[{Prefix}] Server reply: {str.Value}"
};
}
[Request("err")]
public PbString Error(Header header, PbString str)
{
throw new ProcessorMethodException(StatusCode.Failed, "Test Error");
}
[Notify("notify")]
public void Notify(Header header, PbString str)
{
// Console.WriteLine($">>>> Server.Notify Recv: {str.Value}");
Push("test.push", header, new PbString
{
Value = $"Push: {str.Value}"
});
}
public void OnStart()
{
Console.WriteLine("TestProcessor.OnStart");
}
public void OnStop()
{
Console.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] TestProcessor.OnStop-1");
Task.Delay(1000).Wait();
Console.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] TestProcessor.OnStop-2");
}
public Task OnUpdate()
{
m_count++;
// Console.WriteLine($"TestProcessor.OnUpdate[{m_count}] => {DateTime.Now:hh:mm:ss.fff}");
return Task.CompletedTask;
}
}