package matchmaker
import "github.com/Diarkis/diarkis/client/go/modules/matchmaker"
Index
- type ClaimResult
-
type MatchMaker
- func NewMatchMakerAsTCP(tcp *tcp.Client) *MatchMaker
- func NewMatchMakerAsUDP(udp *udp.Client) *MatchMaker
- func (mm *MatchMaker) CancelTicket(ticketType byte)
- func (mm *MatchMaker) CancelTicketBackfill(ticketType byte)
- func (mm *MatchMaker) Claim(roomID string, password string, msg []byte)
- func (mm *MatchMaker) DisbandMatchmaking(profileID string, message []byte)
- func (mm *MatchMaker) GetRoomID() string
- func (mm *MatchMaker) HostMatchmaking(maxMembers uint16, ttl uint16, profileID string, tags []string, ...) bool
- func (mm *MatchMaker) IssueTicket(ticketType byte)
- func (mm *MatchMaker) Kick(id string, profileID string, message []byte)
- func (mm *MatchMaker) Leave(profileID string, message []byte)
- func (mm *MatchMaker) OnCancelTicketBackfillResponse(cb func(ok bool, payload []byte)) bool
- func (mm *MatchMaker) OnClaimPush(cb func(*pmm.ClaimMatchmakingPush))
- func (mm *MatchMaker) OnClaimResponse(cb func(status bool, res *ClaimResult))
- func (mm *MatchMaker) OnDisbandPush(cb func(*pmm.DisbandMatchmakingPush)) bool
- func (mm *MatchMaker) OnDisbandResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnHostChangePush(cb func(userID string)) bool
- func (mm *MatchMaker) OnHostMatchmakingResponse(cb func(status bool, roomID string))
- func (mm *MatchMaker) OnKickPush(cb func(*pmm.KickFromMatchmakingPush)) bool
- func (mm *MatchMaker) OnKickResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnLeavePush(cb func(*pmm.LeaveMatchmakingPush)) bool
- func (mm *MatchMaker) OnLeaveResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnMemberSync(cb func([]byte)) bool
- func (mm *MatchMaker) OnP2PAddressSync(cb func([]netip.Addr)) bool
- func (mm *MatchMaker) OnP2PAddressSyncResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnResultResponse(cb func(bool, []*pmm.SearchResult)) bool
- func (mm *MatchMaker) OnSyncResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnTicketBackfillResponse(cb func(ok bool, payload []byte)) bool
- func (mm *MatchMaker) OnTicketBroadcast(cb func([]byte)) bool
- func (mm *MatchMaker) OnTicketBroadcastResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnTicketCancelPush(cb func([]byte)) bool
- func (mm *MatchMaker) OnTicketCancelResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnTicketComplete(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnTicketIssueResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) OnTicketLeavePush(cb func([]byte)) bool
- func (mm *MatchMaker) OnTicketLeaveResponse(cb func(bool, []byte)) bool
- func (mm *MatchMaker) P2PAddressSync(linkedClientNum byte)
- func (mm *MatchMaker) SearchList(profileIDs []string, tags []string, props map[string]int, howMany uint16)
- func (mm *MatchMaker) Sync(profileID string, message []byte)
- func (mm *MatchMaker) TicketBackfill(ticketType byte)
- func (mm *MatchMaker) TicketBroadcast(ticketType byte, message []byte)
- func (mm *MatchMaker) TicketLeave(ticketType byte)
Types
type ClaimResult
type ClaimResult struct { RoomID string OwnerID string MemberIDs []string }
ClaimResult is the result of a claim matchmaking request.
type MatchMaker
type MatchMaker struct { RoomID string // status Team bool Hosting bool Ticketing bool IsBackfill bool Join bool }
MatchMaker represents Diarkis MatchMaker client
func NewMatchMakerAsTCP
func NewMatchMakerAsTCP(tcp *tcp.Client) *MatchMaker
NewMatchMakerAsTCP creates MatchMaker client as TCP client
func NewMatchMakerAsUDP
func NewMatchMakerAsUDP(udp *udp.Client) *MatchMaker
NewMatchMakerAsUDP creates MatchMaker client as UDP client
func (*MatchMaker) CancelTicket
func (mm *MatchMaker) CancelTicket(ticketType byte)
CancelTicket cancels an issued ticket. Ticket type is a pre-define type of ticket that the user issues to attempt matchmaking. Ticket type is defined on the server and the user must use the valid ticket type that the server has pre-defined.
func (*MatchMaker) CancelTicketBackfill
func (mm *MatchMaker) CancelTicketBackfill(ticketType byte)
CancelTicketBackfill cancels a ticket backfill
func (*MatchMaker) Claim
func (mm *MatchMaker) Claim(roomID string, password string, msg []byte)
Claim tries to join a matchmaking room with the given roomID and password.
func (*MatchMaker) DisbandMatchmaking
func (mm *MatchMaker) DisbandMatchmaking(profileID string, message []byte)
DisbandMatchmaking clear matchmaking and delete room
func (*MatchMaker) GetRoomID
func (mm *MatchMaker) GetRoomID() string
GetRoomID returns the room ID
func (*MatchMaker) HostMatchmaking
func (mm *MatchMaker) HostMatchmaking(maxMembers uint16, ttl uint16, profileID string, tags []string, props map[string]int, metadata []byte, reserveOnly bool, password string) bool
HostMatchmaking registers itself to MatchMaker's matchmaking and wait until matches are made. You may abort matchmaking by calling DisbandMatchmaking. You will become the host of this matchmaking. OnHostMatchmakingResponse will be raised as a server response.
maxMembers is the maximum number of members to be matched.
ttl is the time to live of the matchmaking.
profileIDs Search allows you to search for a match using multiple matchmaking profiles. The order of the server is determined by the order of the ID list. You may, for example, search with very strict matchmaking profile and move to more relaxed ones etc.
tags Search will target hosts only with matching one of the tags.
props Search condition properties.
reserveOnly If set to true, user does not join the room automatically.
metadata Metadata to be sent to the other matched users. Searchers can get this metadata when using SearchList.
password Password to be used to join the room. When calling ClaimMatchmaking, the password must be the same as the one used to host matchmaking.
func (*MatchMaker) IssueTicket
func (mm *MatchMaker) IssueTicket(ticketType byte)
IssueTicket sends a request issue a matchmaking ticket on the server. All matchmaking conditions and logic will be controlled on the server and the client will only be waiting for OnTicketComplete event to be raised.
If the issued ticket fails to create a match, the event will be raised only on the client that issued the ticket. If the issued ticket successfully creates a match, the event will be raised on all the clients that have been matched.
Ticket type is a pre-define type of ticket that the user issues to attempt matchmaking. Ticket type is defined on the server and the user must use the valid ticket type that the server has pre-defined.
func (*MatchMaker) Kick
func (mm *MatchMaker) Kick(id string, profileID string, message []byte)
Kick sends a request to the server to kick a user.
func (*MatchMaker) Leave
func (mm *MatchMaker) Leave(profileID string, message []byte)
Leave sends a request to the server to leave the matchmaking.
func (*MatchMaker) OnCancelTicketBackfillResponse
func (mm *MatchMaker) OnCancelTicketBackfillResponse(cb func(ok bool, payload []byte)) bool
OnCancelTicketBackfillResponse assigns a callback on cancel ticket backfill event
func (*MatchMaker) OnClaimPush
func (mm *MatchMaker) OnClaimPush(cb func(*pmm.ClaimMatchmakingPush))
OnClaimPush sets the callback function for the claim matchmaking push.
func (*MatchMaker) OnClaimResponse
func (mm *MatchMaker) OnClaimResponse(cb func(status bool, res *ClaimResult))
OnClaimResponse sets the callback function for the claim matchmaking response.
func (*MatchMaker) OnDisbandPush
func (mm *MatchMaker) OnDisbandPush(cb func(*pmm.DisbandMatchmakingPush)) bool
OnDisbandPush sets the callback function for disbanding matchmaking.
func (*MatchMaker) OnDisbandResponse
func (mm *MatchMaker) OnDisbandResponse(cb func(bool, []byte)) bool
OnDisbandResponse sets the callback function for disbanding matchmaking.
func (*MatchMaker) OnHostChangePush
func (mm *MatchMaker) OnHostChangePush(cb func(userID string)) bool
OnHostChangePush sets the callback function for the host change push.
func (*MatchMaker) OnHostMatchmakingResponse
func (mm *MatchMaker) OnHostMatchmakingResponse(cb func(status bool, roomID string))
OnHostMatchmakingResponse sets the callback function for the host matchmaking response.
func (*MatchMaker) OnKickPush
func (mm *MatchMaker) OnKickPush(cb func(*pmm.KickFromMatchmakingPush)) bool
OnKickPush sets the callback function for the kick push.
func (*MatchMaker) OnKickResponse
func (mm *MatchMaker) OnKickResponse(cb func(bool, []byte)) bool
OnKickResponse sets the callback function for the kick response.
func (*MatchMaker) OnLeavePush
func (mm *MatchMaker) OnLeavePush(cb func(*pmm.LeaveMatchmakingPush)) bool
OnLeavePush sets the callback function for the leave push.
func (*MatchMaker) OnLeaveResponse
func (mm *MatchMaker) OnLeaveResponse(cb func(bool, []byte)) bool
OnLeaveResponse sets the callback function for the leave response.
func (*MatchMaker) OnMemberSync
func (mm *MatchMaker) OnMemberSync(cb func([]byte)) bool
OnMemberSync sets callback for member sync push
func (*MatchMaker) OnP2PAddressSync
func (mm *MatchMaker) OnP2PAddressSync(cb func([]netip.Addr)) bool
OnP2PAddressSync sets the callback function for the P2P address sync.
func (*MatchMaker) OnP2PAddressSyncResponse
func (mm *MatchMaker) OnP2PAddressSyncResponse(cb func(bool, []byte)) bool
OnP2PAddressSyncResponse sets the callback function for the P2P address sync response.
func (*MatchMaker) OnResultResponse
func (mm *MatchMaker) OnResultResponse(cb func(bool, []*pmm.SearchResult)) bool
OnResultResponse sets the callback function for the search result. This is fired when join = false.
func (*MatchMaker) OnSyncResponse
func (mm *MatchMaker) OnSyncResponse(cb func(bool, []byte)) bool
OnSyncResponse sets callback for sync response
func (*MatchMaker) OnTicketBackfillResponse
func (mm *MatchMaker) OnTicketBackfillResponse(cb func(ok bool, payload []byte)) bool
OnTicketBackfillResponse assigns a callback on ticket backfill event
func (*MatchMaker) OnTicketBroadcast
func (mm *MatchMaker) OnTicketBroadcast(cb func([]byte)) bool
OnTicketBroadcast assigns a callback on ticket broadcast push event
func (*MatchMaker) OnTicketBroadcastResponse
func (mm *MatchMaker) OnTicketBroadcastResponse(cb func(bool, []byte)) bool
OnTicketBroadcastResponse assigns a callback on ticket broadcast event
func (*MatchMaker) OnTicketCancelPush
func (mm *MatchMaker) OnTicketCancelPush(cb func([]byte)) bool
OnTicketCancelPush assigns a callback on ticket cancel event
func (*MatchMaker) OnTicketCancelResponse
func (mm *MatchMaker) OnTicketCancelResponse(cb func(bool, []byte)) bool
OnTicketCancelResponse assigns a callback on ticket cancel event
func (*MatchMaker) OnTicketComplete
func (mm *MatchMaker) OnTicketComplete(cb func(bool, []byte)) bool
OnTicketComplete sets the callback function for the ticket complete.
func (*MatchMaker) OnTicketIssueResponse
func (mm *MatchMaker) OnTicketIssueResponse(cb func(bool, []byte)) bool
OnTicketIssueResponse sets the callback function for the ticket issue response.
func (*MatchMaker) OnTicketLeavePush
func (mm *MatchMaker) OnTicketLeavePush(cb func([]byte)) bool
OnTicketLeavePush assigns a callback on ticket leave push event
func (*MatchMaker) OnTicketLeaveResponse
func (mm *MatchMaker) OnTicketLeaveResponse(cb func(bool, []byte)) bool
OnTicketLeaveResponse assigns a callback on ticket leave event
func (*MatchMaker) P2PAddressSync
func (mm *MatchMaker) P2PAddressSync(linkedClientNum byte)
P2PAddressSync sends a request to the server to get the P2P address of the linked client.
func (*MatchMaker) SearchList
func (mm *MatchMaker) SearchList( profileIDs []string, tags []string, props map[string]int, howMany uint16, )
SearchList actively search for matchmaking using multiple matchmaking profile IDs and get the list of matched rooms. This is used when you want to get the list of matched rooms without joining them.
profileIDs Search allows you to search for a match using multiple matchmaking profiles. The order of the server is determined by the order of the ID list. You may, for example, search with very strict matchmaking profile and move to more relaxed ones etc.
tags Search will target hosts only with matching one of the tags.
props Search condition properties.
howMany Determine maximum how many matched results to expect by the search results.
func (*MatchMaker) Sync
func (mm *MatchMaker) Sync(profileID string, message []byte)
Sync sends sync message to MatchMaker
func (*MatchMaker) TicketBackfill
func (mm *MatchMaker) TicketBackfill(ticketType byte)
TicketBackfill backfills a completed ticket
func (*MatchMaker) TicketBroadcast
func (mm *MatchMaker) TicketBroadcast(ticketType byte, message []byte)
TicketBroadcast broadcasts a message to all users that matched the same ticket. Ticket type is a pre-define type of ticket that the user issues to attempt matchmaking. Ticket type is defined on the server and the user must use the valid ticket type that the server has pre-defined.
func (*MatchMaker) TicketLeave
func (mm *MatchMaker) TicketLeave(ticketType byte)
TicketLeave leaves from a ticket that the user issued or matched. Ticket type is a pre-define type of ticket that the user issues to attempt matchmaking. Ticket type is defined on the server and the user must use the valid ticket type that the server has pre-defined.