github.com/glide-im/glide@v1.6.0/im_service/client/mixed_rpc_impl.go (about) 1 package client 2 3 import ( 4 "github.com/glide-im/glide/pkg/gate" 5 "github.com/glide-im/glide/pkg/messages" 6 "github.com/glide-im/glide/pkg/rpc" 7 "github.com/glide-im/glide/pkg/subscription" 8 ) 9 10 type Client struct { 11 sub *SubscriptionRpcImpl 12 gate *GatewayRpcImpl 13 } 14 15 func NewClient(opts *rpc.ClientOptions) (*Client, error) { 16 cli, err := rpc.NewBaseClient(opts) 17 if err != nil { 18 return nil, err 19 } 20 c := Client{ 21 sub: NewSubscriptionRpcImplWithClient(cli), 22 gate: NewGatewayRpcImplWithClient(cli), 23 } 24 return &c, nil 25 } 26 27 func (c *Client) SetClientID(old gate.ID, new_ gate.ID) error { 28 return c.gate.SetClientID(old, new_) 29 } 30 31 func (c *Client) ExitClient(id gate.ID) error { 32 return c.gate.ExitClient(id) 33 } 34 35 func (c *Client) EnqueueMessage(id gate.ID, message *messages.GlideMessage) error { 36 return c.gate.EnqueueMessage(id, message) 37 } 38 39 func (c *Client) Subscribe(ch subscription.ChanID, id subscription.SubscriberID, extra interface{}) error { 40 return c.sub.Subscribe(ch, id, extra) 41 } 42 43 func (c *Client) UnSubscribe(ch subscription.ChanID, id subscription.SubscriberID) error { 44 return c.sub.UnSubscribe(ch, id) 45 } 46 47 func (c *Client) UpdateSubscriber(ch subscription.ChanID, id subscription.SubscriberID, extra interface{}) error { 48 return c.sub.UpdateSubscriber(ch, id, extra) 49 } 50 51 func (c *Client) RemoveChannel(ch subscription.ChanID) error { 52 return c.sub.RemoveChannel(ch) 53 } 54 55 func (c *Client) CreateChannel(ch subscription.ChanID, update *subscription.ChanInfo) error { 56 return c.sub.CreateChannel(ch, update) 57 } 58 59 func (c *Client) UpdateChannel(ch subscription.ChanID, update *subscription.ChanInfo) error { 60 return c.sub.UpdateChannel(ch, update) 61 } 62 63 func (c *Client) Publish(ch subscription.ChanID, msg subscription.Message) error { 64 return c.sub.Publish(ch, msg) 65 }