assemble

package
v0.0.0-...-744b261 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2019 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

This file is part of Assemble Web Chat.

Assemble Web Chat is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Assemble Web Chat is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Assemble Web Chat. If not, see <http://www.gnu.org/licenses/>.

This file is part of Assemble Web Chat.

Assemble Web Chat is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Assemble Web Chat is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Assemble Web Chat. If not, see <http://www.gnu.org/licenses/>.

This file is part of Assemble Web Chat.

Assemble Web Chat is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Assemble Web Chat is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Assemble Web Chat. If not, see <http://www.gnu.org/licenses/>.

This file is part of Assemble Web Chat.

Assemble Web Chat is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Assemble Web Chat is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Assemble Web Chat. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateNewUserToken

func CreateNewUserToken(nick, name, email, phone, url, desc, avatar, alertaddress string) (*gabs.Container, error)

func CreateUpdatedUserToken

func CreateUpdatedUserToken(nick, name, email, phone, url, desc, avatar, alertaddress, uid, privid string) (*gabs.Container, error)

func PublicUserString

func PublicUserString(token *gabs.Container) string

Types

type Err

type Err struct {
	// contains filtered or unexported fields
}

Err general error holder

func (*Err) Error

func (e *Err) Error() string

type OnlineUser

type OnlineUser struct {
	So       *socketio.Socket
	LastPing time.Time
}

OnlineUser has info for and online user including last active timestamp

type Room

type Room struct {
	FriendlyName  string
	RoomID        string
	IsPrivate     bool
	IsDirect      bool
	CreatorUID    string
	MemberUIDs    map[string]string
	InvitedUIDs   map[string]string
	DirectUIDs    map[string]string
	MaxExpTime    time.Duration
	MinExpTime    time.Duration
	Avatar        string
	MaxHistoryLen int
	Messages      []*gabs.Container
}

Room contains all room info, messages, user list, etc

type Service

type Service struct {
	SocketServer *socketio.Server

	Cfg         *config.Config
	Rooms       map[string]*Room
	Users       map[string]*User
	OnlineUsers map[string]*OnlineUser
	Invites     map[string]string
	Banlist     map[string]string
	UserKey     []byte
	DefMaxExp   time.Duration
	DefMinExp   time.Duration

	IconsJs string
}

Service holds the key parts of the assemble server

func NewService

func NewService(cfg *config.Config, userkey []byte) *Service

NewService creates an assemble server

func (*Service) AddToRoom

func (svc *Service) AddToRoom(so socketio.Socket, uid string, room string)

func (*Service) BroadcastUserLeave

func (svc *Service) BroadcastUserLeave(room string, uid string, so socketio.Socket)

func (*Service) CanJoin

func (svc *Service) CanJoin(uid string, room string, removeinvite bool) bool

func (*Service) CreateRoom

func (svc *Service) CreateRoom(fname, roomid string, isprivate, isdirect bool, creatoruid string, maxexptime time.Duration, minexptime time.Duration, avatar string, maxhistorylen int) *Room

CreateRoom adds a room to the services list

func (*Service) CreateRoomList

func (svc *Service) CreateRoomList() string

func (*Service) ExtractAndCheckToken

func (svc *Service) ExtractAndCheckToken(so socketio.Socket, g *gabs.Container) (string, bool)

func (*Service) JoinRoom

func (svc *Service) JoinRoom(so socketio.Socket, uid string, room string)

func (*Service) JoinRooms

func (svc *Service) JoinRooms(so socketio.Socket, uid string)

func (*Service) SendAlert

func (svc *Service) SendAlert(toaddr, subject, message string)

func (*Service) SendOnlineUserList

func (svc *Service) SendOnlineUserList(so socketio.Socket)

func (*Service) SendRoomHistory

func (svc *Service) SendRoomHistory(so socketio.Socket, uid, room string, last int)

func (*Service) SendRoomUserList

func (svc *Service) SendRoomUserList(so socketio.Socket, room string)

func (*Service) SetUserOnline

func (svc *Service) SetUserOnline(uid string, so socketio.Socket)

func (*Service) Start

func (svc *Service) Start()

Start listens and sets up goroutines

func (*Service) ValidateUserToken

func (svc *Service) ValidateUserToken(so socketio.Socket, msg string) (string, error)

type User

type User struct {
	LastAlert     time.Time
	LastAct       time.Time
	Token         *gabs.Container
	AlertsEnabled bool
}

User holds info about a user who has used this server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL