Documentation ¶
Overview ¶
* MIT License
Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* MIT License
Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- func EventHandler(msg *common.Message, ctx *Context)
- type Broadcast
- type Connection
- type Context
- type DataHandler
- type EventFunc
- type Room
- type Session
- type Sockets
- func (s *Sockets) Broadcast(event string, data, options interface{})
- func (s *Sockets) BroadcastToRoom(roomName, event string, data interface{}, ctx *Context)
- func (s *Sockets) BroadcastToRoomChannel(roomName, channelName, event string, data interface{}, ctx *Context)
- func (s *Sockets) CheckIfSessionExists(username string) bool
- func (s *Sockets) Close()
- func (s *Sockets) GetUserRoom(username, uuid string) (string, error)
- func (s *Sockets) HandleConnection(w http.ResponseWriter, r *http.Request) error
- func (s *Sockets) HandleEvent(pattern string, handler EventFunc)
- func (s *Sockets) InterruptHandler()
- func (s *Sockets) JoinRoom(room, uuid string) error
- func (s *Sockets) JoinRoomChannel(channel, uuid string) error
- func (s *Sockets) LeaveRoom(uuid string)
- func (s *Sockets) NewUserSession(username string, conn *Connection)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EventHandler ¶
Types ¶
type Connection ¶
type Connection struct { UUID string Conn *websocket.Conn Status bool `json:"status"` Room *Room `json:"room"` *Session }
func NewConnection ¶ added in v1.4.0
func NewConnection() *Connection
func (*Connection) AddSession ¶ added in v1.4.0
func (c *Connection) AddSession(session *Session)
func (*Connection) ClearSession ¶ added in v1.4.0
func (c *Connection) ClearSession(session *Session)
func (*Connection) Emit ¶ added in v1.4.0
func (c *Connection) Emit(msg interface{}) error
type Context ¶
type Context struct { *Connection UUID string }
type DataHandler ¶
type Sockets ¶
type Sockets struct { Connections map[string]*Connection Sessions map[string]*Session sync.Mutex // contains filtered or unexported fields }
func New ¶
func New(handler DataHandler) *Sockets
func (*Sockets) BroadcastToRoom ¶
func (*Sockets) BroadcastToRoomChannel ¶
func (*Sockets) CheckIfSessionExists ¶ added in v1.4.0
func (*Sockets) HandleConnection ¶
func (*Sockets) HandleEvent ¶
func (*Sockets) InterruptHandler ¶
func (s *Sockets) InterruptHandler()
func (*Sockets) JoinRoomChannel ¶
func (*Sockets) NewUserSession ¶ added in v1.4.0
func (s *Sockets) NewUserSession(username string, conn *Connection)
Directories ¶
Path | Synopsis |
---|---|
* MIT License Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
* MIT License Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
* MIT License Copyright (c) 2018 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
* MIT License Copyright (c) 2018 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
examples
|
|
client
* MIT License Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
* MIT License Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
server
* MIT License Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
* MIT License Copyright (c) 2018-2019 Andrew Zak <andrew@linux.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |