-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
68 lines (45 loc) · 958 Bytes
/
interface.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package define
import (
"bytes"
"log/slog"
"time"
"github.com/panshiqu/golang/timer"
"github.com/panshiqu/server/pb"
"google.golang.org/protobuf/proto"
)
type IRoom interface {
Logger() *slog.Logger
IsNobody() bool
// 游戏遍历用户
LenUsers() int
GetUser(int) IUser
Disband()
Send(*pb.Msg, ...int64)
SendPb(pb.Cmd, proto.Message, ...int64) error
Add(time.Duration, func(...any) error, ...any) *timer.Timer
AddRepeat(time.Duration, func(...any) error, ...any) *timer.Timer
}
type IUser interface {
ID() int64
Seat() int
Data() any
IsOnline() bool
Logger() *slog.Logger
IsWatcher() bool
SetData(any)
Error(error, string, ...any)
StandUp(int)
Disband()
Disconnect(int)
Send(*pb.Msg) error
SendPb(pb.Cmd, proto.Message) error
}
type IGame interface {
Init(IRoom) error
Reconnect(IUser)
SitDown(IUser)
StandUp(IUser, int) bool
OnDisband(int64)
OnMessage(IUser, *pb.Msg) error
Print(*bytes.Buffer)
}