-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MatchmakeExtension::CreateMatchmakeSessionWithParam
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
matchmake-extension/create_matchmake_session_with_param.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package matchmake_extension | ||
|
||
import ( | ||
nex "github.com/PretendoNetwork/nex-go" | ||
"github.com/PretendoNetwork/nex-protocols-go/globals" | ||
match_making "github.com/PretendoNetwork/nex-protocols-go/match-making" | ||
) | ||
|
||
// CreateMatchmakeSessionWithParam sets the CreateMatchmakeSessionWithParam handler function | ||
func (protocol *MatchmakeExtensionProtocol) CreateMatchmakeSessionWithParam(handler func(err error, client *nex.Client, callID uint32, createMatchmakeSessionParam *match_making.CreateMatchmakeSessionParam)) { | ||
protocol.CreateMatchmakeSessionWithParamHandler = handler | ||
} | ||
|
||
func (protocol *MatchmakeExtensionProtocol) HandleCreateMatchmakeSessionWithParam(packet nex.PacketInterface) { | ||
if protocol.CreateMatchmakeSessionWithParamHandler == nil { | ||
globals.Logger.Warning("MatchmakeExtension::CreateMatchmakeSessionWithParam not implemented") | ||
go globals.RespondNotImplemented(packet, ProtocolID) | ||
return | ||
} | ||
|
||
client := packet.Sender() | ||
request := packet.RMCRequest() | ||
|
||
callID := request.CallID() | ||
parameters := request.Parameters() | ||
|
||
parametersStream := nex.NewStreamIn(parameters, protocol.Server) | ||
|
||
createMatchmakeSessionParam, err := parametersStream.ReadStructure(match_making.NewCreateMatchmakeSessionParam()) | ||
if err != nil { | ||
go protocol.CreateMatchmakeSessionWithParamHandler(err, client, callID, nil) | ||
return | ||
} | ||
|
||
go protocol.CreateMatchmakeSessionWithParamHandler(nil, client, callID, createMatchmakeSessionParam.(*match_making.CreateMatchmakeSessionParam)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters