-
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::JoinMatchmakeSessionWithParam
- Loading branch information
Showing
3 changed files
with
106 additions
and
1 deletion.
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
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" | ||
) | ||
|
||
// JoinMatchmakeSessionWithParam sets the JoinMatchmakeSessionWithParam handler function | ||
func (protocol *MatchmakeExtensionProtocol) JoinMatchmakeSessionWithParam(handler func(err error, client *nex.Client, callID uint32, joinMatchmakeSessionParam *match_making.JoinMatchmakeSessionParam)) { | ||
protocol.JoinMatchmakeSessionWithParamHandler = handler | ||
} | ||
|
||
func (protocol *MatchmakeExtensionProtocol) HandleJoinMatchmakeSessionWithParam(packet nex.PacketInterface) { | ||
if protocol.JoinMatchmakeSessionWithParamHandler == nil { | ||
globals.Logger.Warning("MatchmakeExtension::JoinMatchmakeSessionWithParam 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) | ||
|
||
joinMatchmakeSessionParam, err := parametersStream.ReadStructure(match_making.NewJoinMatchmakeSessionParam()) | ||
if err != nil { | ||
go protocol.JoinMatchmakeSessionWithParamHandler(err, client, callID, nil) | ||
return | ||
} | ||
|
||
go protocol.JoinMatchmakeSessionWithParamHandler(nil, client, callID, joinMatchmakeSessionParam.(*match_making.JoinMatchmakeSessionParam)) | ||
} |
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