示例#1
0
文件: main.go 项目: Yuhang/xserver
func init() {
	if port := args.RpcListenPort(); port != 0 {
		srv = newServer(port)
	}
	if ip, port := args.RpcRemote(); port != 0 {
		clt = newClient(ip, port)
	}
}
示例#2
0
文件: rpc.go 项目: Yuhang/xserver
func newXRequest(xid uint32, raddr *net.UDPAddr, code string, callback float64, data []byte, reliable bool) ([]byte, error) {
	port := uint32(args.RpcListenPort())
	x := &XRequest{}
	x.Port = &port
	x.Code = &code
	x.Reliable = &reliable
	x.Callback = &callback
	if raddr != nil {
		addr := raddr.String()
		x.Addr = &addr
	}
	if len(data) != 0 {
		x.Data = data
	}
	x.Xid = &xid
	return proto.Marshal(x)
}