Skip to content

Commit

Permalink
Playing with xml streams and adium
Browse files Browse the repository at this point in the history
  • Loading branch information
djworth committed Nov 25, 2013
1 parent e5453fa commit 2a9eb16
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 121 deletions.
47 changes: 47 additions & 0 deletions core.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"bufio"
"fmt"
"net"
)

func Serve(addr string) {
ln, err := net.Listen("tcp", addr)
if err != nil {
// handle error
}
for {
conn, err := ln.Accept()
if err != nil {
// handle error
continue
}

go handleConnection(conn)
}
}

func handleConnection(conn net.Conn) {
b := bufio.NewReader(conn)

fmt.Fprintf(conn, `<?xml version='1.0'?>
<stream:stream
from='localhost'
id='abc123'
to='djworth@localhost'
version='1.0'
xml:lang='en'
xmlns='jabber:server'
xmlns:stream='http://etherx.jabber.org/streams'>`)

fmt.Fprintf(conn, "<stream:features/>")
for {
line, _, err := b.ReadLine()
if err != nil {
break
}
fmt.Println(string(line))
}

}
45 changes: 0 additions & 45 deletions hub.go

This file was deleted.

12 changes: 2 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
package main

import (
"code.google.com/p/go.net/websocket"
"flag"
"log"
"net/http"
)

var addr = flag.String("addr", ":8080", "http service address")
var listen = flag.String("listen", ":5222", "xmpp service address")

func main() {
flag.Parse()
go h.run()

http.Handle("/ws", websocket.Handler(wsHandler))
if err := http.ListenAndServe(*addr, nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
Serve(*listen)
}
66 changes: 0 additions & 66 deletions ws.go

This file was deleted.

0 comments on commit 2a9eb16

Please sign in to comment.