summaryrefslogtreecommitdiff
path: root/src/pkg/websocket/websocket.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2009-12-15 15:41:46 -0800
committerRobert Griesemer <gri@golang.org>2009-12-15 15:41:46 -0800
commit3743fa38e180c74c51aae84eda082067e8e12523 (patch)
tree274d1d9bf832b7834ab60c65acdf945576271d14 /src/pkg/websocket/websocket.go
parent13ac778ef2f757c7cd636b4336a2bd6c8f403b43 (diff)
downloadgolang-3743fa38e180c74c51aae84eda082067e8e12523.tar.gz
1) Change default gofmt default settings for
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 5th and last set of files. R=rsc CC=golang-dev http://codereview.appspot.com/180050
Diffstat (limited to 'src/pkg/websocket/websocket.go')
-rw-r--r--src/pkg/websocket/websocket.go74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/pkg/websocket/websocket.go b/src/pkg/websocket/websocket.go
index 373961d57..efcb228b3 100644
--- a/src/pkg/websocket/websocket.go
+++ b/src/pkg/websocket/websocket.go
@@ -12,52 +12,52 @@ package websocket
// better logging.
import (
- "bufio";
- "io";
- "net";
- "os";
+ "bufio"
+ "io"
+ "net"
+ "os"
)
type WebSocketAddr string
-func (addr WebSocketAddr) Network() string { return "websocket" }
+func (addr WebSocketAddr) Network() string { return "websocket" }
-func (addr WebSocketAddr) String() string { return string(addr) }
+func (addr WebSocketAddr) String() string { return string(addr) }
// Conn is an channels to communicate over Web Socket.
type Conn struct {
// An origin URI of the Web Socket.
- Origin string;
+ Origin string
// A location URI of the Web Socket.
- Location string;
+ Location string
// A subprotocol of the Web Socket.
- Protocol string;
+ Protocol string
- buf *bufio.ReadWriter;
- rwc io.ReadWriteCloser;
+ buf *bufio.ReadWriter
+ rwc io.ReadWriteCloser
}
// newConn creates a new Web Socket.
func newConn(origin, location, protocol string, buf *bufio.ReadWriter, rwc io.ReadWriteCloser) *Conn {
if buf == nil {
- br := bufio.NewReader(rwc);
- bw := bufio.NewWriter(rwc);
- buf = bufio.NewReadWriter(br, bw);
+ br := bufio.NewReader(rwc)
+ bw := bufio.NewWriter(rwc)
+ buf = bufio.NewReadWriter(br, bw)
}
- ws := &Conn{origin, location, protocol, buf, rwc};
- return ws;
+ ws := &Conn{origin, location, protocol, buf, rwc}
+ return ws
}
func (ws *Conn) Read(msg []byte) (n int, err os.Error) {
for {
- frameByte, err := ws.buf.ReadByte();
+ frameByte, err := ws.buf.ReadByte()
if err != nil {
return n, err
}
if (frameByte & 0x80) == 0x80 {
- length := 0;
+ length := 0
for {
- c, err := ws.buf.ReadByte();
+ c, err := ws.buf.ReadByte()
if err != nil {
return n, err
}
@@ -68,15 +68,15 @@ func (ws *Conn) Read(msg []byte) (n int, err os.Error) {
}
}
for length > 0 {
- _, err := ws.buf.ReadByte();
+ _, err := ws.buf.ReadByte()
if err != nil {
return n, err
}
- length--;
+ length--
}
} else {
for {
- c, err := ws.buf.ReadByte();
+ c, err := ws.buf.ReadByte()
if err != nil {
return n, err
}
@@ -87,8 +87,8 @@ func (ws *Conn) Read(msg []byte) (n int, err os.Error) {
if n+1 <= cap(msg) {
msg = msg[0 : n+1]
}
- msg[n] = c;
- n++;
+ msg[n] = c
+ n++
}
if n >= cap(msg) {
return n, os.E2BIG
@@ -97,42 +97,42 @@ func (ws *Conn) Read(msg []byte) (n int, err os.Error) {
}
}
- panic("unreachable");
+ panic("unreachable")
}
func (ws *Conn) Write(msg []byte) (n int, err os.Error) {
- ws.buf.WriteByte(0);
- ws.buf.Write(msg);
- ws.buf.WriteByte(0xff);
- err = ws.buf.Flush();
- return len(msg), err;
+ ws.buf.WriteByte(0)
+ ws.buf.Write(msg)
+ ws.buf.WriteByte(0xff)
+ err = ws.buf.Flush()
+ return len(msg), err
}
-func (ws *Conn) Close() os.Error { return ws.rwc.Close() }
+func (ws *Conn) Close() os.Error { return ws.rwc.Close() }
-func (ws *Conn) LocalAddr() net.Addr { return WebSocketAddr(ws.Origin) }
+func (ws *Conn) LocalAddr() net.Addr { return WebSocketAddr(ws.Origin) }
-func (ws *Conn) RemoteAddr() net.Addr { return WebSocketAddr(ws.Location) }
+func (ws *Conn) RemoteAddr() net.Addr { return WebSocketAddr(ws.Location) }
func (ws *Conn) SetTimeout(nsec int64) os.Error {
if conn, ok := ws.rwc.(net.Conn); ok {
return conn.SetTimeout(nsec)
}
- return os.EINVAL;
+ return os.EINVAL
}
func (ws *Conn) SetReadTimeout(nsec int64) os.Error {
if conn, ok := ws.rwc.(net.Conn); ok {
return conn.SetReadTimeout(nsec)
}
- return os.EINVAL;
+ return os.EINVAL
}
func (ws *Conn) SetWriteTimeout(nsec int64) os.Error {
if conn, ok := ws.rwc.(net.Conn); ok {
return conn.SetWriteTimeout(nsec)
}
- return os.EINVAL;
+ return os.EINVAL
}
-var _ net.Conn = (*Conn)(nil) // compile-time check that *Conn implements net.Conn.
+var _ net.Conn = (*Conn)(nil) // compile-time check that *Conn implements net.Conn.