2017-08-14 02:04:35 +00:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/s-rah/go-ricochet/channels"
|
|
|
|
"github.com/s-rah/go-ricochet/connection"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ContactProtocolHandler struct {
|
|
|
|
connection.AutoConnectionHandler
|
|
|
|
conn *connection.Connection
|
|
|
|
contact *Contact
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewContactProtocolHandler(contact *Contact, conn *connection.Connection) *ContactProtocolHandler {
|
|
|
|
handler := &ContactProtocolHandler{
|
|
|
|
conn: conn,
|
|
|
|
contact: contact,
|
|
|
|
}
|
2017-09-16 10:12:46 +00:00
|
|
|
handler.Init()
|
2017-08-14 02:04:35 +00:00
|
|
|
|
|
|
|
handler.RegisterChannelHandler("im.ricochet.chat", func() channels.Handler {
|
2017-09-16 10:12:46 +00:00
|
|
|
chat := &channels.ChatChannel{
|
|
|
|
Handler: contact.Conversation(),
|
|
|
|
}
|
2017-08-14 02:04:35 +00:00
|
|
|
return chat
|
|
|
|
})
|
|
|
|
|
|
|
|
return handler
|
|
|
|
}
|