mirror of
https://github.com/raz-varren/sacrificial-socket.git
synced 2025-10-09 01:50:07 +08:00
I fmted
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
package ssgrpc
|
package ssgrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"google.golang.org/grpc"
|
|
||||||
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/transport"
|
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/transport"
|
||||||
|
"google.golang.org/grpc"
|
||||||
//"sync"
|
//"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
package ssgrpc
|
package ssgrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"golang.org/x/net/context"
|
|
||||||
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/token"
|
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/token"
|
||||||
"github.com/raz-varren/sacrificial-socket/log"
|
"github.com/raz-varren/sacrificial-socket/log"
|
||||||
|
"golang.org/x/net/context"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@@ -3,12 +3,12 @@ package ssgrpc
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
ss "github.com/raz-varren/sacrificial-socket"
|
ss "github.com/raz-varren/sacrificial-socket"
|
||||||
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/token"
|
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/token"
|
||||||
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/transport"
|
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/transport"
|
||||||
"github.com/raz-varren/sacrificial-socket/log"
|
"github.com/raz-varren/sacrificial-socket/log"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
"google.golang.org/grpc/metadata"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
@@ -2,13 +2,13 @@ package ssgrpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
ss "github.com/raz-varren/sacrificial-socket"
|
||||||
|
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/transport"
|
||||||
|
"github.com/raz-varren/sacrificial-socket/log"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
"net"
|
"net"
|
||||||
ss "github.com/raz-varren/sacrificial-socket"
|
|
||||||
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc/transport"
|
|
||||||
"github.com/raz-varren/sacrificial-socket/log"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@@ -2,11 +2,11 @@ package ssmongo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
ss "github.com/raz-varren/sacrificial-socket"
|
||||||
|
"github.com/raz-varren/sacrificial-socket/log"
|
||||||
"gopkg.in/mgo.v2"
|
"gopkg.in/mgo.v2"
|
||||||
"gopkg.in/mgo.v2/bson"
|
"gopkg.in/mgo.v2/bson"
|
||||||
"io"
|
"io"
|
||||||
ss "github.com/raz-varren/sacrificial-socket"
|
|
||||||
"github.com/raz-varren/sacrificial-socket/log"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@@ -3,11 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
|
"github.com/raz-varren/sacrificial-socket"
|
||||||
|
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"github.com/raz-varren/sacrificial-socket"
|
|
||||||
"github.com/raz-varren/sacrificial-socket/backend/ssgrpc"
|
|
||||||
"strings"
|
"strings"
|
||||||
//"time"
|
//"time"
|
||||||
)
|
)
|
||||||
@@ -108,13 +108,13 @@ func EchoJSON(s *ss.Socket, data []byte) {
|
|||||||
func Join(s *ss.Socket, data []byte) {
|
func Join(s *ss.Socket, data []byte) {
|
||||||
d := string(data)
|
d := string(data)
|
||||||
s.Join(d)
|
s.Join(d)
|
||||||
s.Emit("echo", "joined room:" + d)
|
s.Emit("echo", "joined room:"+d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Leave(s *ss.Socket, data []byte) {
|
func Leave(s *ss.Socket, data []byte) {
|
||||||
d := string(data)
|
d := string(data)
|
||||||
s.Leave(d)
|
s.Leave(d)
|
||||||
s.Emit("echo", "left room:" + d)
|
s.Emit("echo", "left room:"+d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Roomcast(s *ss.Socket, data []byte) {
|
func Roomcast(s *ss.Socket, data []byte) {
|
||||||
@@ -141,12 +141,11 @@ func RoomcastJSON(s *ss.Socket, data []byte) {
|
|||||||
s.Roomcast(r.Room, "roomcastjson", r)
|
s.Roomcast(r.Room, "roomcastjson", r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func Broadcast(s *ss.Socket, data []byte) {
|
func Broadcast(s *ss.Socket, data []byte) {
|
||||||
s.Broadcast("broadcast", string(data))
|
s.Broadcast("broadcast", string(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func BroadcastBin(s *ss.Socket, data []byte){
|
func BroadcastBin(s *ss.Socket, data []byte) {
|
||||||
s.Broadcast("broadcastbin", data)
|
s.Broadcast("broadcastbin", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,9 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
ss "github.com/raz-varren/sacrificial-socket"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
ss "github.com/raz-varren/sacrificial-socket"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@@ -8,12 +8,12 @@ Sacrificial-Socket also has a MultihomeBackend interface for syncronizing broadc
|
|||||||
package ss
|
package ss
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/raz-varren/sacrificial-socket/log"
|
||||||
"golang.org/x/net/websocket"
|
"golang.org/x/net/websocket"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"github.com/raz-varren/sacrificial-socket/log"
|
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
@@ -158,14 +158,13 @@ func (serv *SocketServer) loop(ws *websocket.Conn) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
eventName := ""
|
eventName := ""
|
||||||
contentIdx := 0
|
contentIdx := 0
|
||||||
|
|
||||||
for idx, chr := range msg {
|
for idx, chr := range msg {
|
||||||
if chr == startOfDataByte {
|
if chr == startOfDataByte {
|
||||||
eventName = string(msg[:idx])
|
eventName = string(msg[:idx])
|
||||||
contentIdx = idx+1
|
contentIdx = idx + 1
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,10 @@ package ss_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"github.com/raz-varren/sacrificial-socket"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"github.com/raz-varren/sacrificial-socket"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExampleNewServer() {
|
func ExampleNewServer() {
|
||||||
|
@@ -3,9 +3,9 @@ package ss
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"golang.org/x/net/websocket"
|
|
||||||
"github.com/raz-varren/sacrificial-socket/log"
|
"github.com/raz-varren/sacrificial-socket/log"
|
||||||
"github.com/raz-varren/sacrificial-socket/tools"
|
"github.com/raz-varren/sacrificial-socket/tools"
|
||||||
|
"golang.org/x/net/websocket"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user