Added params to session

This commit is contained in:
Heikki Uljas
2016-01-13 08:03:00 +02:00
parent 241a6879bf
commit cf8236b938
2 changed files with 12 additions and 0 deletions
+11
View File
@@ -10,6 +10,7 @@ import (
// A melody session.
type Session struct {
Request *http.Request
params map[string]string
conn *websocket.Conn
output chan *envelope
melody *Melody
@@ -117,3 +118,13 @@ func (s *Session) WriteBinary(msg []byte) {
func (s *Session) Close() {
s.writeMessage(&envelope{t: websocket.CloseMessage, msg: []byte{}})
}
// Set session param
func (s *Session) SetParam(key string, value string) {
s.params[key] = value
}
// Get session param
func (s *Session) GetParam(key string) string {
return s.params[key]
}