Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
43 changed files
with
1,407 additions
and
1,316 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.swp | ||
profile.out | ||
*.coverprofile |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1 @@ | ||
/* | ||
Package gosockjs is an concurrent safe implementation of a SockJS server. The core design principles are described | ||
here http://blog.igormihalik.com/2012/12/sockjs-for-go.html and source code can be found on github https://github.com/igm/sockjs-go | ||
*/ | ||
package sockjs |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package sockjs_test | ||
|
||
import ( | ||
"net/http" | ||
|
||
"sockjs-go.v3/sockjs" | ||
) | ||
|
||
func ExampleNewHandler_simple() { | ||
handler := sockjs.NewHandler("/echo", sockjs.DefaultOptions, func(con sockjs.Conn) { | ||
var msg string | ||
var err error | ||
for { | ||
if msg, err = con.Recv(); err != nil { | ||
break | ||
} | ||
if err = con.Send(msg); err != nil { | ||
break | ||
} | ||
} | ||
}) | ||
http.ListenAndServe(":8080", handler) | ||
} | ||
|
||
func ExampleNewHandler_defaultMux() { | ||
handler := sockjs.NewHandler("/echo", sockjs.DefaultOptions, func(con sockjs.Conn) { | ||
var msg string | ||
var err error | ||
for { | ||
if msg, err = con.Recv(); err != nil { | ||
break | ||
} | ||
if err = con.Send(msg); err != nil { | ||
break | ||
} | ||
} | ||
}) | ||
// need to provide path prefix for http.Mux | ||
http.Handle("/echo/", handler) | ||
http.ListenAndServe(":8080", nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sockjs | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
) | ||
|
||
func closeFrame(status uint32, reason string) string { | ||
bytes, _ := json.Marshal([]interface{}{status, reason}) | ||
return fmt.Sprintf("c%s", string(bytes)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package sockjs | ||
|
||
import "testing" | ||
|
||
func TestCloseFrame(t *testing.T) { | ||
cf := closeFrame(1024, "some close text") | ||
if cf != "c[1024,\"some close text\"]" { | ||
t.Errorf("Wrong close frame generated '%s'", cf) | ||
} | ||
} |
Oops, something went wrong.