disconnect

This commit is contained in:
Dan Ballard 2017-09-23 09:05:09 -07:00
parent 4d7017402d
commit 81906f08f6
2 changed files with 14 additions and 3 deletions

View File

@ -70,8 +70,6 @@ func (odClient *ODClient) Connect(privateKeyData string, serverAddr string) erro
log.Println("ODClient: Authenticated") log.Println("ODClient: Authenticated")
log.Println("go")
log.Println("RequestOpenChanel chat") log.Println("RequestOpenChanel chat")
err = odClient.connection.RequestOpenChannel("im.ricochet.chat", odClient) err = odClient.connection.RequestOpenChannel("im.ricochet.chat", odClient)
if err != nil { if err != nil {
@ -84,6 +82,13 @@ func (odClient *ODClient) Connect(privateKeyData string, serverAddr string) erro
return nil return nil
} }
func (odClient *ODClient) Disconnect() {
log.Println("Break()...")
odClient.connection.Break()
log.Println("Conn.Close()...")
odClient.connection.Conn.Close()
}
/*func (odClient *ODClient) RequestContact() { /*func (odClient *ODClient) RequestContact() {
odClient.connection.Do(func() error { odClient.connection.Do(func() error {
channel := odClient.connection.Channel("im.ricochet.contact.request", channels.Outbound) channel := odClient.connection.Channel("im.ricochet.contact.request", channels.Outbound)

View File

@ -17,7 +17,7 @@ var (
// moddified // moddified
levelArr = []int{1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6} levelArr = []int{1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6}
odClient *ODClient.ODClient odClient *ODClient.ODClient = nil
) )
func GeneratePrivateKey() (string, error) { func GeneratePrivateKey() (string, error) {
@ -45,6 +45,12 @@ func ODClientConnect(privateKey string, serverAddr string) error {
return err return err
} }
func ODClientDisconnect() {
log.Println("ODClientDisconnect()")
odClient.Disconnect()
odClient = nil
}
func GetDeviceName() string { func GetDeviceName() string {
odClient.SendMessage("/name") odClient.SendMessage("/name")
name := odClient.GetMessage() name := odClient.GetMessage()