-
Notifications
You must be signed in to change notification settings - Fork 11
/
clear_buffer_queues.go
47 lines (36 loc) · 1.64 KB
/
clear_buffer_queues.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Package protocol implements the DataStoreSuperMarioMaker protocol
package protocol
import (
"fmt"
nex "github.com/PretendoNetwork/nex-go"
datastore_super_mario_maker_types "github.com/PretendoNetwork/nex-protocols-go/datastore/super-mario-maker/types"
"github.com/PretendoNetwork/nex-protocols-go/globals"
)
// ClearBufferQueues sets the ClearBufferQueues handler function
func (protocol *Protocol) ClearBufferQueues(handler func(err error, packet nex.PacketInterface, callID uint32, params []*datastore_super_mario_maker_types.BufferQueueParam) uint32) {
protocol.clearBufferQueuesHandler = handler
}
func (protocol *Protocol) handleClearBufferQueues(packet nex.PacketInterface) {
var errorCode uint32
if protocol.clearBufferQueuesHandler == nil {
globals.Logger.Warning("DataStoreSuperMarioMaker::ClearBufferQueues not implemented")
go globals.RespondError(packet, ProtocolID, nex.Errors.Core.NotImplemented)
return
}
request := packet.RMCRequest()
callID := request.CallID()
parameters := request.Parameters()
parametersStream := nex.NewStreamIn(parameters, protocol.Server)
params, err := parametersStream.ReadListStructure(datastore_super_mario_maker_types.NewBufferQueueParam())
if err != nil {
errorCode = protocol.clearBufferQueuesHandler(fmt.Errorf("Failed to read params from parameters. %s", err.Error()), packet, callID, nil)
if errorCode != 0 {
globals.RespondError(packet, ProtocolID, errorCode)
}
return
}
errorCode = protocol.clearBufferQueuesHandler(nil, packet, callID, params.([]*datastore_super_mario_maker_types.BufferQueueParam))
if errorCode != 0 {
globals.RespondError(packet, ProtocolID, errorCode)
}
}