mirror of
https://github.com/statbate/special-pancake.git
synced 2026-08-11 03:12:42 +00:00
remove
This commit is contained in:
parent
03732ea80d
commit
249b30961f
4 changed files with 3 additions and 47 deletions
|
|
@ -113,5 +113,4 @@ func startRoom(workerData Info) {
|
||||||
workerData.ch = make(chan struct{})
|
workerData.ch = make(chan struct{})
|
||||||
|
|
||||||
go xWorker(workerData, url.URL{Scheme: "wss", Host: "realtime.pa.highwebmedia.com", Path: "/", RawQuery: "access_token=" + workerData.Auth + "&format=json&heartbeats=true&v=1.2&agent=ably-js%2F1.2.13%20browser&remainPresentFor=0"})
|
go xWorker(workerData, url.URL{Scheme: "wss", Host: "realtime.pa.highwebmedia.com", Path: "/", RawQuery: "access_token=" + workerData.Auth + "&format=json&heartbeats=true&v=1.2&agent=ably-js%2F1.2.13%20browser&remainPresentFor=0"})
|
||||||
//go xWorker(workerData)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
app/main.go
17
app/main.go
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
@ -45,8 +44,6 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
|
|
||||||
startConfig()
|
startConfig()
|
||||||
|
|
||||||
initMysql()
|
initMysql()
|
||||||
|
|
@ -122,20 +119,6 @@ func socketHandler() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func randInt(min int, max int) int {
|
|
||||||
return min + rand.Intn(max-min)
|
|
||||||
}
|
|
||||||
|
|
||||||
func randString(n int) string {
|
|
||||||
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
||||||
var bytes = make([]byte, n)
|
|
||||||
rand.Read(bytes)
|
|
||||||
for i, b := range bytes {
|
|
||||||
bytes[i] = alphanum[b%byte(len(alphanum))]
|
|
||||||
}
|
|
||||||
return string(bytes)
|
|
||||||
}
|
|
||||||
|
|
||||||
func fastStart() {
|
func fastStart() {
|
||||||
defer func() {
|
defer func() {
|
||||||
go updateFileRooms()
|
go updateFileRooms()
|
||||||
|
|
|
||||||
|
|
@ -80,8 +80,9 @@ func saveDB() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-sendIndex.C:
|
case <-sendIndex.C:
|
||||||
if time.Now().Minute() >= 5 && tokens > 0 {
|
t := time.Now()
|
||||||
passed := time.Now().Second() + time.Now().Minute()*60
|
if t.Minute() >= 5 && tokens > 0 {
|
||||||
|
passed := t.Second() + t.Minute()*60
|
||||||
msg, err := json.Marshal(struct {
|
msg, err := json.Marshal(struct {
|
||||||
Chanel string `json:"chanel"`
|
Chanel string `json:"chanel"`
|
||||||
Index int64 `json:"index"`
|
Index int64 `json:"index"`
|
||||||
|
|
@ -93,7 +94,6 @@ func saveDB() {
|
||||||
socketServer <- msg
|
socketServer <- msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-cleanCache.C:
|
case <-cleanCache.C:
|
||||||
l := len(data)
|
l := len(data)
|
||||||
now := time.Now().Unix()
|
now := time.Now().Unix()
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
//"net/url"
|
|
||||||
//"strconv"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -68,15 +66,6 @@ func announceCount() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func reconnectRoom(workerData Info) {
|
|
||||||
n := randInt(10, 30)
|
|
||||||
fmt.Printf("Sleeping %d seconds...\n", n)
|
|
||||||
time.Sleep(time.Duration(n) * time.Second)
|
|
||||||
fmt.Println("reconnect:", workerData.room, workerData.Id, workerData.Auth, workerData.Proxy)
|
|
||||||
workerData.Last = time.Now().Unix()
|
|
||||||
startRoom(workerData)
|
|
||||||
}
|
|
||||||
|
|
||||||
func xWorker(workerData Info, u url.URL) {
|
func xWorker(workerData Info, u url.URL) {
|
||||||
|
|
||||||
fmt.Println("Start", workerData.room, "room_id", workerData.Id, "auth", workerData.Auth, "proxy", workerData.Proxy)
|
fmt.Println("Start", workerData.room, "room_id", workerData.Id, "auth", workerData.Auth, "proxy", workerData.Proxy)
|
||||||
|
|
@ -152,11 +141,6 @@ func xWorker(workerData Info, u url.URL) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//if input.Key == "" {
|
|
||||||
// fmt.Println("no connectionKey", workerData.room, string(message))
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
if err = c.WriteMessage(websocket.TextMessage, []byte(`{"action":17, "auth":{"accessToken":"`+workerData.Auth+`"}}`)); err != nil {
|
if err = c.WriteMessage(websocket.TextMessage, []byte(`{"action":17, "auth":{"accessToken":"`+workerData.Auth+`"}}`)); err != nil {
|
||||||
fmt.Println(err.Error(), workerData.room)
|
fmt.Println(err.Error(), workerData.room)
|
||||||
return
|
return
|
||||||
|
|
@ -168,13 +152,6 @@ func xWorker(workerData Info, u url.URL) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//fmt.Println(`{"action":16, "connectionKey":"`+input.Key+`","connectionSerial": -1}`)
|
|
||||||
|
|
||||||
//if err = c.WriteMessage(websocket.TextMessage, []byte(`{"action":16, "connectionKey":"`+input.Key+`","connectionSerial": -1}`)); err != nil {
|
|
||||||
// fmt.Println(err.Error(), workerData.room)
|
|
||||||
// return
|
|
||||||
//}
|
|
||||||
|
|
||||||
for _, im := range initMessages {
|
for _, im := range initMessages {
|
||||||
if err = c.WriteMessage(websocket.TextMessage, []byte(im)); err != nil {
|
if err = c.WriteMessage(websocket.TextMessage, []byte(im)); err != nil {
|
||||||
fmt.Println(err.Error(), workerData.room)
|
fmt.Println(err.Error(), workerData.room)
|
||||||
|
|
@ -195,9 +172,6 @@ func xWorker(workerData Info, u url.URL) {
|
||||||
_, message, err := c.ReadMessage()
|
_, message, err := c.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error(), workerData.room)
|
fmt.Println(err.Error(), workerData.room)
|
||||||
//if workerData.Income > 1 {
|
|
||||||
// go reconnectRoom(workerData)
|
|
||||||
//}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue