You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
679 B

5 years ago
  1. package connect
  2. import (
  3. "gopkg.in/olahol/melody.v1"
  4. )
  5. type Client struct {
  6. Id string // account_typ:account_id
  7. AccountId int64
  8. AccountType string
  9. Pid int64
  10. Online bool
  11. RoomId string
  12. node *Node
  13. *melody.Session
  14. }
  15. func NewClient(session *melody.Session, node *Node, roomId string) *Client {
  16. client := new(Client)
  17. client.Session = session
  18. client.node = node
  19. client.Online = false
  20. client.RoomId = roomId
  21. return client
  22. }
  23. func (c *Client) BroadcastAll(msg *Message) {
  24. c.node.BroadcastAll(msg, c)
  25. }
  26. func (c *Client) Register() error {
  27. return c.node.RegisterClient(c)
  28. }
  29. func (c *Client) Send(msg *Message) {
  30. c.node.Send(msg)
  31. }