MCPcopy
hub / github.com/aceld/zinx / Handle

Method Handle

examples/zinx_protobuf/server/server.go:18–45  ·  view source on GitHub ↗

Ping Handle

(request ziface.IRequest)

Source from the content-addressed store, hash-verified

16
17// Ping Handle
18func (this *PositionServerRouter) Handle(request ziface.IRequest) {
19
20 msg := &pb.Position{}
21 err := proto.Unmarshal(request.GetData(), msg)
22 if err != nil {
23 fmt.Println("Position Unmarshal error ", err, " data = ", request.GetData())
24 return
25 }
26
27 fmt.Printf("recv from client : msgId=%+v, data=%+v\n", request.GetMsgID(), msg)
28
29 msg.X += 1
30 msg.Y += 1
31 msg.Z += 1
32 msg.V += 1
33
34 data, err := proto.Marshal(msg)
35 if err != nil {
36 fmt.Println("proto Marshal error = ", err, " msg = ", msg)
37 return
38 }
39
40 err = request.GetConnection().SendMsg(0, data)
41
42 if err != nil {
43 zlog.Error(err)
44 }
45}
46
47func main() {
48 s := znet.NewServer()

Callers

nothing calls this directly

Calls 5

ErrorFunction · 0.92
GetDataMethod · 0.65
GetMsgIDMethod · 0.65
SendMsgMethod · 0.65
GetConnectionMethod · 0.65

Tested by

no test coverage detected