Documentation ¶
Index ¶
- Constants
- type EntitySyncInfo
- type GoWorldConnection
- func (gwc *GoWorldConnection) Close() error
- func (gwc *GoWorldConnection) Flush(reason string) error
- func (gwc *GoWorldConnection) IsClosed() bool
- func (gwc *GoWorldConnection) LocalAddr() net.Addr
- func (gwc *GoWorldConnection) Recv(msgtype *MsgType) (*netutil.Packet, error)
- func (gwc *GoWorldConnection) RemoteAddr() net.Addr
- func (gwc *GoWorldConnection) SendCallEntityMethod(id common.EntityID, method string, args []interface{}) error
- func (gwc *GoWorldConnection) SendCallEntityMethodFromClient(id common.EntityID, method string, args []interface{}) error
- func (gwc *GoWorldConnection) SendCallEntityMethodOnClient(gid uint16, clientid common.ClientID, entityID common.EntityID, method string, ...) (err error)
- func (gwc *GoWorldConnection) SendCallFilterClientProxies(key string, val string, method string, args []interface{}) (err error)
- func (gwc *GoWorldConnection) SendClearClientFilterProp(gid uint16, clientid common.ClientID) (err error)
- func (gwc *GoWorldConnection) SendCreateEntityAnywhere(typeName string, data map[string]interface{}) error
- func (gwc *GoWorldConnection) SendCreateEntityOnClient(gid uint16, clientid common.ClientID, typeName string, ...) error
- func (gwc *GoWorldConnection) SendDeclareService(id common.EntityID, serviceName string) error
- func (gwc *GoWorldConnection) SendDestroyEntityOnClient(gid uint16, clientid common.ClientID, typeName string, ...) error
- func (gwc *GoWorldConnection) SendLoadEntityAnywhere(typeName string, entityID common.EntityID) error
- func (gwc *GoWorldConnection) SendMigrateRequest(spaceID common.EntityID, entityID common.EntityID) error
- func (gwc *GoWorldConnection) SendNotifyClientConnected(id common.ClientID) error
- func (gwc *GoWorldConnection) SendNotifyClientDisconnected(id common.ClientID) error
- func (gwc *GoWorldConnection) SendNotifyCreateEntity(id common.EntityID) error
- func (gwc *GoWorldConnection) SendNotifyDestroyEntity(id common.EntityID) error
- func (gwc *GoWorldConnection) SendNotifyListAttrAppendOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, ...) error
- func (gwc *GoWorldConnection) SendNotifyListAttrChangeOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, ...) error
- func (gwc *GoWorldConnection) SendNotifyListAttrPopOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, ...) error
- func (gwc *GoWorldConnection) SendNotifyMapAttrChangeOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, ...) error
- func (gwc *GoWorldConnection) SendNotifyMapAttrDelOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, ...) error
- func (gwc *GoWorldConnection) SendPacket(packet *netutil.Packet) error
- func (gwc *GoWorldConnection) SendPacketRelease(packet *netutil.Packet) error
- func (gwc *GoWorldConnection) SendRealMigrate(eid common.EntityID, targetGame uint16, targetSpace common.EntityID, ...) error
- func (gwc *GoWorldConnection) SendSetClientClientID(clientid common.ClientID) error
- func (gwc *GoWorldConnection) SendSetClientFilterProp(gid uint16, clientid common.ClientID, key, val string) (err error)
- func (gwc *GoWorldConnection) SendSetGameID(id uint16, isReconnect bool, isRestore bool) error
- func (gwc *GoWorldConnection) SendSetGateID(id uint16) error
- func (gwc *GoWorldConnection) SendStartFreezeGame(gameid uint16) error
- func (gwc *GoWorldConnection) SendSyncPositionOnClient(gid uint16, clientid common.ClientID, entityID common.EntityID, ...) error
- func (gwc *GoWorldConnection) SendSyncPositionYawFromClient(entityID common.EntityID, x, y, z float32, yaw float32) error
- func (gwc *GoWorldConnection) SetAutoFlush(interval time.Duration)
- func (gwc *GoWorldConnection) SetHeartbeatFromClient() error
- func (gwc *GoWorldConnection) SetRecvDeadline(deadline time.Time) error
- func (gwc *GoWorldConnection) String() string
- type MsgType
Constants ¶
const ( // MT_INVALID is the invalid message type MT_INVALID = iota // MT_SET_GAME_ID is a message type for game MT_SET_GAME_ID // MT_SET_GATE_ID is a message type for gate MT_SET_GATE_ID // MT_NOTIFY_CREATE_ENTITY is a message type for creating entities MT_NOTIFY_CREATE_ENTITY // MT_NOTIFY_DESTROY_ENTITY is a message type for destroying entities MT_NOTIFY_DESTROY_ENTITY // MT_DECLARE_SERVICE is a message type for declaring services MT_DECLARE_SERVICE // MT_UNDECLARE_SERVICE is a message type for undeclaring services MT_UNDECLARE_SERVICE // MT_CALL_ENTITY_METHOD is a message type for calling entity methods MT_CALL_ENTITY_METHOD // MT_CREATE_ENTITY_ANYWHERE is a message type for creating entities MT_CREATE_ENTITY_ANYWHERE // MT_LOAD_ENTITY_ANYWHERE is a message type loading entities MT_LOAD_ENTITY_ANYWHERE // MT_NOTIFY_CLIENT_CONNECTED is a message type for clients MT_NOTIFY_CLIENT_CONNECTED // MT_NOTIFY_CLIENT_DISCONNECTED is a message type for clients MT_NOTIFY_CLIENT_DISCONNECTED // MT_CALL_ENTITY_METHOD_FROM_CLIENT is a message type for clients MT_CALL_ENTITY_METHOD_FROM_CLIENT // MT_SYNC_POSITION_YAW_FROM_CLIENT is a message type for clients MT_SYNC_POSITION_YAW_FROM_CLIENT // MT_NOTIFY_ALL_GAMES_CONNECTED is a message type to notify all games connected MT_NOTIFY_ALL_GAMES_CONNECTED // MT_NOTIFY_GATE_DISCONNECTED is a message type to notify gate disconnected MT_NOTIFY_GATE_DISCONNECTED // MT_START_FREEZE_GAME is a message type for hot swapping MT_START_FREEZE_GAME // MT_START_FREEZE_GAME_ACK is a message type for hot swapping MT_START_FREEZE_GAME_ACK // MT_MIGRATE_REQUEST is a message type for entity migrations MT_MIGRATE_REQUEST // MT_REAL_MIGRATE is a message type for entity migrations MT_REAL_MIGRATE )
const ( // MT_GATE_SERVICE_MSG_TYPE_START is the first message types that should be handled by GateService MT_GATE_SERVICE_MSG_TYPE_START = 1000 + iota // MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_START is the first message type that should be redirected to client proxy MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_START // MT_CREATE_ENTITY_ON_CLIENT message type MT_CREATE_ENTITY_ON_CLIENT // MT_DESTROY_ENTITY_ON_CLIENT message type MT_DESTROY_ENTITY_ON_CLIENT // MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT message type MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT // MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT message type MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT // MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT message type MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT // MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT message type MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT // MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT message type MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT // MT_CALL_ENTITY_METHOD_ON_CLIENT message type MT_CALL_ENTITY_METHOD_ON_CLIENT // MT_UPDATE_POSITION_ON_CLIENT message type MT_UPDATE_POSITION_ON_CLIENT // MT_UPDATE_YAW_ON_CLIENT message type MT_UPDATE_YAW_ON_CLIENT // MT_SET_CLIENTPROXY_FILTER_PROP message type MT_SET_CLIENTPROXY_FILTER_PROP // MT_CLEAR_CLIENTPROXY_FILTER_PROPS message type MT_CLEAR_CLIENTPROXY_FILTER_PROPS // MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_STOP message type MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_STOP = 1499 )
const ( // MT_CALL_FILTERED_CLIENTS message type: messages to be processed by GateService from Dispatcher, but not redirected to clients MT_CALL_FILTERED_CLIENTS = 1501 + iota // MT_SYNC_POSITION_YAW_ON_CLIENTS message type MT_SYNC_POSITION_YAW_ON_CLIENTS // MT_GATE_SERVICE_MSG_TYPE_STOP message type MT_GATE_SERVICE_MSG_TYPE_STOP = 1999 )
const ( // MT_SET_CLIENT_CLIENTID message is sent to client to set its clientid MT_SET_CLIENT_CLIENTID = 2001 + iota MT_UDP_SYNC_CONN_NOTIFY_CLIENTID MT_UDP_SYNC_CONN_NOTIFY_CLIENTID_ACK // MT_HEARTBEAT_FROM_CLIENT is sent by client to notify the gate server that the client is alive MT_HEARTBEAT_FROM_CLIENT )
Messages types that is sent directly between Gate & Client
const ( // SYNC_INFO_SIZE_PER_ENTITY is the size of sync info per entity SYNC_INFO_SIZE_PER_ENTITY = 16 UDP_SYNC_PACKET_SIZE = common.ENTITYID_LENGTH + SYNC_INFO_SIZE_PER_ENTITY )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntitySyncInfo ¶
EntitySyncInfo defines fields of entity sync info
type GoWorldConnection ¶
type GoWorldConnection struct {
// contains filtered or unexported fields
}
GoWorldConnection is the network protocol implementation of GoWorld components (dispatcher, gate, game)
func NewGoWorldConnection ¶
func NewGoWorldConnection(conn netutil.Connection, compressConnection bool, compressFormat string) *GoWorldConnection
NewGoWorldConnection creates a GoWorldConnection using network connection
func (*GoWorldConnection) Flush ¶
func (gwc *GoWorldConnection) Flush(reason string) error
Flush connection writes
func (*GoWorldConnection) IsClosed ¶
func (gwc *GoWorldConnection) IsClosed() bool
IsClosed returns if the connection is closed
func (*GoWorldConnection) LocalAddr ¶
func (gwc *GoWorldConnection) LocalAddr() net.Addr
LocalAddr returns the local address
func (*GoWorldConnection) Recv ¶
func (gwc *GoWorldConnection) Recv(msgtype *MsgType) (*netutil.Packet, error)
Recv receives the next packet and retrive the message type
func (*GoWorldConnection) RemoteAddr ¶
func (gwc *GoWorldConnection) RemoteAddr() net.Addr
RemoteAddr returns the remote address
func (*GoWorldConnection) SendCallEntityMethod ¶
func (gwc *GoWorldConnection) SendCallEntityMethod(id common.EntityID, method string, args []interface{}) error
SendCallEntityMethod sends MT_CALL_ENTITY_METHOD message
func (*GoWorldConnection) SendCallEntityMethodFromClient ¶
func (gwc *GoWorldConnection) SendCallEntityMethodFromClient(id common.EntityID, method string, args []interface{}) error
SendCallEntityMethodFromClient sends MT_CALL_ENTITY_METHOD_FROM_CLIENT message
func (*GoWorldConnection) SendCallEntityMethodOnClient ¶
func (gwc *GoWorldConnection) SendCallEntityMethodOnClient(gid uint16, clientid common.ClientID, entityID common.EntityID, method string, args []interface{}) (err error)
SendCallEntityMethodOnClient sends MT_CALL_ENTITY_METHOD_ON_CLIENT message
func (*GoWorldConnection) SendCallFilterClientProxies ¶
func (gwc *GoWorldConnection) SendCallFilterClientProxies(key string, val string, method string, args []interface{}) (err error)
SendCallFilterClientProxies sends MT_CALL_FILTERED_CLIENTS message
func (*GoWorldConnection) SendClearClientFilterProp ¶
func (gwc *GoWorldConnection) SendClearClientFilterProp(gid uint16, clientid common.ClientID) (err error)
SendClearClientFilterProp sends MT_CLEAR_CLIENTPROXY_FILTER_PROPS message
func (*GoWorldConnection) SendCreateEntityAnywhere ¶
func (gwc *GoWorldConnection) SendCreateEntityAnywhere(typeName string, data map[string]interface{}) error
SendCreateEntityAnywhere sends MT_CREATE_ENTITY_ANYWHERE message
func (*GoWorldConnection) SendCreateEntityOnClient ¶
func (gwc *GoWorldConnection) SendCreateEntityOnClient(gid uint16, clientid common.ClientID, typeName string, entityid common.EntityID, isPlayer bool, clientData map[string]interface{}, x, y, z float32, yaw float32) error
SendCreateEntityOnClient sends MT_CREATE_ENTITY_ON_CLIENT message
func (*GoWorldConnection) SendDeclareService ¶
func (gwc *GoWorldConnection) SendDeclareService(id common.EntityID, serviceName string) error
SendDeclareService sends MT_DECLARE_SERVICE message
func (*GoWorldConnection) SendDestroyEntityOnClient ¶
func (gwc *GoWorldConnection) SendDestroyEntityOnClient(gid uint16, clientid common.ClientID, typeName string, entityid common.EntityID) error
SendDestroyEntityOnClient sends MT_DESTROY_ENTITY_ON_CLIENT message
func (*GoWorldConnection) SendLoadEntityAnywhere ¶
func (gwc *GoWorldConnection) SendLoadEntityAnywhere(typeName string, entityID common.EntityID) error
SendLoadEntityAnywhere sends MT_LOAD_ENTITY_ANYWHERE message
func (*GoWorldConnection) SendMigrateRequest ¶
func (gwc *GoWorldConnection) SendMigrateRequest(spaceID common.EntityID, entityID common.EntityID) error
SendMigrateRequest sends MT_MIGRATE_REQUEST message
func (*GoWorldConnection) SendNotifyClientConnected ¶
func (gwc *GoWorldConnection) SendNotifyClientConnected(id common.ClientID) error
SendNotifyClientConnected sends MT_NOTIFY_CLIENT_CONNECTED message
func (*GoWorldConnection) SendNotifyClientDisconnected ¶
func (gwc *GoWorldConnection) SendNotifyClientDisconnected(id common.ClientID) error
SendNotifyClientDisconnected sends MT_NOTIFY_CLIENT_DISCONNECTED message
func (*GoWorldConnection) SendNotifyCreateEntity ¶
func (gwc *GoWorldConnection) SendNotifyCreateEntity(id common.EntityID) error
SendNotifyCreateEntity sends MT_NOTIFY_CREATE_ENTITY message
func (*GoWorldConnection) SendNotifyDestroyEntity ¶
func (gwc *GoWorldConnection) SendNotifyDestroyEntity(id common.EntityID) error
SendNotifyDestroyEntity sends MT_NOTIFY_DESTROY_ENTITY message
func (*GoWorldConnection) SendNotifyListAttrAppendOnClient ¶
func (gwc *GoWorldConnection) SendNotifyListAttrAppendOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, val interface{}) error
SendNotifyListAttrAppendOnClient sends MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT message
func (*GoWorldConnection) SendNotifyListAttrChangeOnClient ¶
func (gwc *GoWorldConnection) SendNotifyListAttrChangeOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, index uint32, val interface{}) error
SendNotifyListAttrChangeOnClient sends MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT message
func (*GoWorldConnection) SendNotifyListAttrPopOnClient ¶
func (gwc *GoWorldConnection) SendNotifyListAttrPopOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}) error
SendNotifyListAttrPopOnClient sends MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT message
func (*GoWorldConnection) SendNotifyMapAttrChangeOnClient ¶
func (gwc *GoWorldConnection) SendNotifyMapAttrChangeOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, key string, val interface{}) error
SendNotifyMapAttrChangeOnClient sends MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT message
func (*GoWorldConnection) SendNotifyMapAttrDelOnClient ¶
func (gwc *GoWorldConnection) SendNotifyMapAttrDelOnClient(gid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, key string) error
SendNotifyMapAttrDelOnClient sends MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT message
func (*GoWorldConnection) SendPacket ¶
func (gwc *GoWorldConnection) SendPacket(packet *netutil.Packet) error
SendPacket send a packet to remote
func (*GoWorldConnection) SendPacketRelease ¶
func (gwc *GoWorldConnection) SendPacketRelease(packet *netutil.Packet) error
SendPacketRelease send a packet to remote and then release the packet
func (*GoWorldConnection) SendRealMigrate ¶
func (gwc *GoWorldConnection) SendRealMigrate(eid common.EntityID, targetGame uint16, targetSpace common.EntityID, x, y, z float32, typeName string, migrateData map[string]interface{}, timerData []byte, clientid common.ClientID, clientsrv uint16) error
SendRealMigrate sends MT_REAL_MIGRATE message
func (*GoWorldConnection) SendSetClientClientID ¶
func (gwc *GoWorldConnection) SendSetClientClientID(clientid common.ClientID) error
func (*GoWorldConnection) SendSetClientFilterProp ¶
func (gwc *GoWorldConnection) SendSetClientFilterProp(gid uint16, clientid common.ClientID, key, val string) (err error)
SendSetClientFilterProp sends MT_SET_CLIENTPROXY_FILTER_PROP message
func (*GoWorldConnection) SendSetGameID ¶
func (gwc *GoWorldConnection) SendSetGameID(id uint16, isReconnect bool, isRestore bool) error
SendSetGameID sends MT_SET_GAME_ID message
func (*GoWorldConnection) SendSetGateID ¶
func (gwc *GoWorldConnection) SendSetGateID(id uint16) error
SendSetGateID sends MT_SET_GATE_ID message
func (*GoWorldConnection) SendStartFreezeGame ¶
func (gwc *GoWorldConnection) SendStartFreezeGame(gameid uint16) error
SendStartFreezeGame sends MT_START_FREEZE_GAME message
func (*GoWorldConnection) SendSyncPositionOnClient ¶
func (gwc *GoWorldConnection) SendSyncPositionOnClient(gid uint16, clientid common.ClientID, entityID common.EntityID, x, y, z float32) error
SendSyncPositionOnClient sends MT_UPDATE_POSITION_ON_CLIENT message
func (*GoWorldConnection) SendSyncPositionYawFromClient ¶
func (gwc *GoWorldConnection) SendSyncPositionYawFromClient(entityID common.EntityID, x, y, z float32, yaw float32) error
SendSyncPositionYawFromClient sends MT_SYNC_POSITION_YAW_FROM_CLIENT message
func (*GoWorldConnection) SetAutoFlush ¶
func (gwc *GoWorldConnection) SetAutoFlush(interval time.Duration)
SetAutoFlush starts a goroutine to flush connection writes at some specified interval
func (*GoWorldConnection) SetHeartbeatFromClient ¶
func (gwc *GoWorldConnection) SetHeartbeatFromClient() error
func (*GoWorldConnection) SetRecvDeadline ¶
func (gwc *GoWorldConnection) SetRecvDeadline(deadline time.Time) error
SetRecvDeadline set receive deadline
func (*GoWorldConnection) String ¶
func (gwc *GoWorldConnection) String() string