forked from mbk-lab/rui_orig
2
0
Fork 0

Added the RemoteAddr function to Session interface

This commit is contained in:
Alexei Anoshenko 2022-03-19 19:36:13 +03:00
parent 29164a2416
commit 7f7dcfb746
2 changed files with 12 additions and 1 deletions

View File

@ -33,8 +33,10 @@ type Session interface {
Color(tag string) (Color, bool)
// SetCustomTheme set the custom theme
SetCustomTheme(name string) bool
// UserAgent() returns the "user-agent" text of the client browser
// UserAgent returns the "user-agent" text of the client browser
UserAgent() string
// RemoteAddr returns the client address.
RemoteAddr() string
// Language returns the current session language
Language() string
// SetLanguage set the current session language
@ -430,3 +432,7 @@ func (session *sessionData) SetTitle(title string) {
func (session *sessionData) SetTitleColor(color Color) {
session.runScript(`setTitleColor("` + color.cssString() + `");`)
}
func (session *sessionData) RemoteAddr() string {
return session.brige.remoteAddr()
}

View File

@ -14,6 +14,7 @@ type WebBrige interface {
RunGetterScript(script string) DataObject
AnswerReceived(answer DataObject)
Close()
remoteAddr() string
}
type wsBrige struct {
@ -122,3 +123,7 @@ func (brige *wsBrige) AnswerReceived(answer DataObject) {
ErrorLog("answerID not found")
}
}
func (brige *wsBrige) remoteAddr() string {
return brige.conn.RemoteAddr().String()
}