Пример #1
0
func (u *User) AddServer(server *common.IRCServer) (*common.IRCServer, error) {
	server.Id = int(u.serverIdSeq.Incr())
	server.UserId = u.Id
	server.Active = false

	servers := []*common.IRCServer{server}

	err := common.RedisSliceSave(u.ServerListKey(), &servers)
	if err != nil {
		return nil, err
	}

	manager.zmq.Send <- common.MakeZmqMsg(u.Id, server.Id, common.ZmqAddServer{ServerInfo: server})

	return server, nil
}
Пример #2
0
func (u *User) SendChatMsg(serverid int, target, message string) {
	manager.zmq.Send <- common.MakeZmqMsg(u.Id, serverid, common.ZmqSendChat{Target: target, Message: message})
}
Пример #3
0
func (u *User) AddChannelMsg(serverid int, channel string) {
	manager.zmq.Send <- common.MakeZmqMsg(u.Id, serverid, common.ZmqAddChannel{Channel: &common.IRCChannel{Name: channel}})
}
Пример #4
0
func (u *User) DelChannel(serverId int, channel string) {
	manager.zmq.Send <- common.MakeZmqMsg(u.Id, serverId, common.ZmqDelChannel{Channel: channel})
}
Пример #5
0
func (u *User) JoinPartChannel(serverId int, channel string, join bool) {
	manager.zmq.Send <- common.MakeZmqMsg(u.Id, serverId, common.ZmqJoinPartChannel{Channel: channel, Join: join})
}
Пример #6
0
func (c *IRCClient) MakeZmqMsg(packet common.ZmqPacket) *common.ZmqMsg {
	return common.MakeZmqMsg(c.UserId, c.ServerId, packet)
}