-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 736e931
Showing
21 changed files
with
2,328 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
# websocket |
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,12 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/goravel/framework/facades" | ||
) | ||
|
||
func init() { | ||
config := facades.Config() | ||
config.Add("websocket", map[string]any{ | ||
|
||
}) | ||
} |
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 @@ | ||
package contracts | ||
|
||
type Websocket interface {} |
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,28 @@ | ||
package events | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/event" | ||
"github.com/goravel/framework/facades" | ||
) | ||
|
||
type ClientConnectEvent struct { | ||
UserId string | ||
ClientId string | ||
Time string | ||
} | ||
|
||
func NewClientConnectEvent(UserId string, ClientId string, Time string) error { | ||
err := facades.Event().Job(&ClientConnectEvent{}, []event.Arg{ | ||
{Type: "string", Value: UserId}, | ||
{Type: "string", Value: ClientId}, | ||
{Type: "string", Value: Time}, | ||
}).Dispatch() | ||
return err | ||
} | ||
|
||
func (receiver *ClientConnectEvent) Handle(args []event.Arg) ([]event.Arg, error) { | ||
receiver.UserId = args[0].Value.(string) | ||
receiver.ClientId = args[1].Value.(string) | ||
receiver.Time = args[2].Value.(string) | ||
return args, 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,28 @@ | ||
package events | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/event" | ||
"github.com/goravel/framework/facades" | ||
) | ||
|
||
type ClientDisConnectEvent struct { | ||
UserId string | ||
ClientId string | ||
Time uint64 | ||
} | ||
|
||
func NewClientDisConnectEvent(UserId string, ClientId string, Time uint64) error { | ||
err := facades.Event().Job(&ClientDisConnectEvent{}, []event.Arg{ | ||
{Type: "string", Value: UserId}, | ||
{Type: "string", Value: ClientId}, | ||
{Type: "string", Value: Time}, | ||
}).Dispatch() | ||
return err | ||
} | ||
|
||
func (receiver *ClientDisConnectEvent) Handle(args []event.Arg) ([]event.Arg, error) { | ||
receiver.UserId = args[0].Value.(string) | ||
receiver.ClientId = args[1].Value.(string) | ||
receiver.Time = args[2].Value.(uint64) | ||
return args, 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,28 @@ | ||
package events | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/event" | ||
"github.com/goravel/framework/facades" | ||
) | ||
|
||
type ClientKeepLiveEvent struct { | ||
UserId string | ||
ClientId string | ||
Time string | ||
} | ||
|
||
func NewClientKeepLiveEvent(UserId string, ClientId string, Time string) error { | ||
err := facades.Event().Job(&ClientKeepLiveEvent{}, []event.Arg{ | ||
{Type: "string", Value: UserId}, | ||
{Type: "string", Value: ClientId}, | ||
{Type: "string", Value: Time}, | ||
}).Dispatch() | ||
return err | ||
} | ||
|
||
func (receiver *ClientKeepLiveEvent) Handle(args []event.Arg) ([]event.Arg, error) { | ||
receiver.UserId = args[0].Value.(string) | ||
receiver.ClientId = args[1].Value.(string) | ||
receiver.Time = args[2].Value.(string) | ||
return args, 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,28 @@ | ||
package events | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/event" | ||
"github.com/goravel/framework/facades" | ||
) | ||
|
||
type ClientKillEvent struct { | ||
UserId string | ||
ClientId string | ||
Time string | ||
} | ||
|
||
func NewClientKillEvent(UserId string, ClientId string, Time string) error { | ||
err := facades.Event().Job(&ClientKillEvent{}, []event.Arg{ | ||
{Type: "string", Value: UserId}, | ||
{Type: "string", Value: ClientId}, | ||
{Type: "string", Value: Time}, | ||
}).Dispatch() | ||
return err | ||
} | ||
|
||
func (receiver *ClientKillEvent) Handle(args []event.Arg) ([]event.Arg, error) { | ||
receiver.UserId = args[0].Value.(string) | ||
receiver.ClientId = args[1].Value.(string) | ||
receiver.Time = args[2].Value.(string) | ||
return args, 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,55 @@ | ||
package events | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/event" | ||
"github.com/goravel/framework/facades" | ||
) | ||
|
||
type ClientMessageSuccessEvent struct { | ||
UserId string | ||
ClientId string | ||
Time string | ||
MessageId string | ||
} | ||
type ClientMessageFailEvent struct { | ||
UserId string | ||
ClientId string | ||
Time string | ||
MessageId string | ||
} | ||
|
||
func NewClientMessageSuccessEvent(userId, clientId, time, messageId string) error { | ||
err := facades.Event().Job(&ClientMessageSuccessEvent{}, []event.Arg{ | ||
{Type: "string", Value: userId}, | ||
{Type: "string", Value: clientId}, | ||
{Type: "string", Value: time}, | ||
{Type: "string", Value: messageId}, | ||
}).Dispatch() | ||
return err | ||
} | ||
|
||
func (receiver *ClientMessageSuccessEvent) Handle(args []event.Arg) ([]event.Arg, error) { | ||
receiver.UserId = args[0].Value.(string) | ||
receiver.ClientId = args[1].Value.(string) | ||
receiver.Time = args[2].Value.(string) | ||
receiver.MessageId = args[3].Value.(string) | ||
return args, nil | ||
} | ||
|
||
func NewClientMessageFailEvent(userId, clientId, time, messageId string) error { | ||
err := facades.Event().Job(&ClientMessageFailEvent{}, []event.Arg{ | ||
{Type: "string", Value: userId}, | ||
{Type: "string", Value: clientId}, | ||
{Type: "string", Value: time}, | ||
{Type: "string", Value: messageId}, | ||
}).Dispatch() | ||
return err | ||
} | ||
|
||
func (receiver *ClientMessageFailEvent) Handle(args []event.Arg) ([]event.Arg, error) { | ||
receiver.UserId = args[0].Value.(string) | ||
receiver.ClientId = args[1].Value.(string) | ||
receiver.Time = args[2].Value.(string) | ||
receiver.MessageId = args[3].Value.(string) | ||
return args, 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,28 @@ | ||
package events | ||
|
||
import ( | ||
"github.com/goravel/framework/contracts/event" | ||
"github.com/goravel/framework/facades" | ||
) | ||
|
||
type ClientOffloneEvent struct { | ||
UserId string | ||
ClientId string | ||
Time string | ||
} | ||
|
||
func NewClientOffloneEvent(UserId string, ClientId string, Time string) error { | ||
err := facades.Event().Job(&ClientOffloneEvent{}, []event.Arg{ | ||
{Type: "string", Value: UserId}, | ||
{Type: "string", Value: ClientId}, | ||
{Type: "string", Value: Time}, | ||
}).Dispatch() | ||
return err | ||
} | ||
|
||
func (receiver *ClientOffloneEvent) Handle(args []event.Arg) ([]event.Arg, error) { | ||
receiver.UserId = args[0].Value.(string) | ||
receiver.ClientId = args[1].Value.(string) | ||
receiver.Time = args[2].Value.(string) | ||
return args, 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,18 @@ | ||
package facades | ||
|
||
import ( | ||
websocket "github.com/okami-chen/goravel-websocket" | ||
"log" | ||
|
||
"github.com/okami-chen/goravel-websocket/contracts" | ||
) | ||
|
||
func Websocket() contracts.Websocket { | ||
instance, err := websocket.App.Make(websocket.Binding) | ||
if err != nil { | ||
log.Println(err) | ||
return nil | ||
} | ||
|
||
return instance.(contracts.Websocket) | ||
} |
Oops, something went wrong.