package ipb import "sync/atomic" func MakeMsg(serviceName string, connId uint32, userId int64, msgId int32, msg []byte) *InternalMsg { return &InternalMsg{ ServiceName: serviceName, ConnId: connId, UserId: userId, MsgId: msgId, Msg: msg, } } func MakeRpcMsg(serviceName string, connId uint32, userId int64, msgId int32, msg []byte) *InternalMsg { return &InternalMsg{ ServiceName: serviceName, ConnId: connId, UserId: userId, MsgId: msgId, Msg: msg, Type: MsgType_RpcMsg, RetRpcMsgId: genRpcId(), } } const ( rpcBeginId = -500000 rpcEndId = -100000 ) var rpcId int32 func genRpcId() int32 { if atomic.LoadInt32(&rpcId) > rpcEndId { atomic.StoreInt32(&rpcId, rpcBeginId) } return atomic.AddInt32(&rpcId, 1) }