Skip to content

Commit

Permalink
Use any
Browse files Browse the repository at this point in the history
  • Loading branch information
Fizzadar committed Oct 29, 2024
1 parent def1314 commit a5ff17c
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions mcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (mcs *mcs) ReceiveVersion() error {
return nil
}

func (mcs *mcs) PerformReadTag() (interface{}, error) {
func (mcs *mcs) PerformReadTag() (any, error) {
var err error

// receive tag
Expand Down Expand Up @@ -191,8 +191,8 @@ func (mcs *mcs) PerformReadTag() (interface{}, error) {
return mcs.UnmarshalTagData(tag, buf)
}

func (mcs *mcs) UnmarshalTagData(tag tagType, buf []byte) (interface{}, error) {
var receive interface{}
func (mcs *mcs) UnmarshalTagData(tag tagType, buf []byte) (any, error) {
var receive any

receiveGenerator, exists := tagMapping[tag]
if exists {
Expand All @@ -216,7 +216,7 @@ func (mcs *mcs) UnmarshalTagData(tag tagType, buf []byte) (interface{}, error) {
return nil, errors.Errorf("unknown tag: %x", tag)
}

func (mcs *mcs) handleTag(receive interface{}) error {
func (mcs *mcs) handleTag(receive any) error {
switch receive := receive.(type) {
case *pb.HeartbeatPing:
mcs.updateIncomingStreamID(receive.GetLastStreamIdReceived())
Expand Down Expand Up @@ -270,16 +270,16 @@ func (mcs *mcs) receiveSize() (int, error) {
}
}

type tagMessageGenerator func() interface{}
type tagMessageGenerator func() any

// Tag mappings.
var tagMapping = map[tagType]tagMessageGenerator{
tagHeartbeatPing: func() interface{} { return &pb.HeartbeatPing{} },
tagHeartbeatAck: func() interface{} { return &pb.HeartbeatAck{} },
tagLoginRequest: func() interface{} { return &pb.LoginRequest{} },
tagLoginResponse: func() interface{} { return &pb.LoginResponse{} },
tagClose: func() interface{} { return &pb.Close{} },
tagIqStanza: func() interface{} { return &pb.IqStanza{} },
tagDataMessageStanza: func() interface{} { return &pb.DataMessageStanza{} },
tagStreamErrorStanza: func() interface{} { return &pb.StreamErrorStanza{} },
tagHeartbeatPing: func() any { return &pb.HeartbeatPing{} },
tagHeartbeatAck: func() any { return &pb.HeartbeatAck{} },
tagLoginRequest: func() any { return &pb.LoginRequest{} },
tagLoginResponse: func() any { return &pb.LoginResponse{} },
tagClose: func() any { return &pb.Close{} },
tagIqStanza: func() any { return &pb.IqStanza{} },
tagDataMessageStanza: func() any { return &pb.DataMessageStanza{} },
tagStreamErrorStanza: func() any { return &pb.StreamErrorStanza{} },
}

0 comments on commit a5ff17c

Please sign in to comment.