✨ Support stream controller event emit
This commit is contained in:
parent
6643d31b1a
commit
27d501d7a7
@ -4,8 +4,12 @@
|
||||
<option name="autoReloadType" value="ALL" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":arrow_up: Upgrade dealer">
|
||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Support stream controller event emit">
|
||||
<change afterPath="$PROJECT_DIR$/pkg/internal/grpc/stream.go" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/pkg/internal/grpc/server.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/grpc/server.go" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -152,7 +156,6 @@
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value=":bug: Fix status query condition" />
|
||||
<MESSAGE value=":bug: Fix disturbable condition" />
|
||||
<MESSAGE value=":sparkles: Admin notify all API" />
|
||||
<MESSAGE value=":bug: Fix request body validation" />
|
||||
@ -177,7 +180,8 @@
|
||||
<MESSAGE value=":recycle: Refactored relation system :arrow_up: Support new realm & relation api" />
|
||||
<MESSAGE value=":bug: Fix model relation issue" />
|
||||
<MESSAGE value=":arrow_up: Upgrade dealer" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value=":arrow_up: Upgrade dealer" />
|
||||
<MESSAGE value=":sparkles: Support stream controller event emit" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Support stream controller event emit" />
|
||||
</component>
|
||||
<component name="VgoProject">
|
||||
<settings-migrated>true</settings-migrated>
|
||||
|
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ toolchain go1.22.1
|
||||
|
||||
require (
|
||||
firebase.google.com/go v3.13.0+incompatible
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240719153055-607eba001f65
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240720114704-037fc8a18c60
|
||||
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745
|
||||
github.com/go-playground/validator/v10 v10.17.0
|
||||
github.com/gofiber/fiber/v2 v2.52.4
|
||||
|
2
go.sum
2
go.sum
@ -21,6 +21,8 @@ git.solsynth.dev/hydrogen/dealer v0.0.0-20240717054512-da433c88615a h1:08YaBgZtk
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240717054512-da433c88615a/go.mod h1:oPdUxLy6TFeRxiRC/BoNb3YUNcnSiOnJrzFTnCPSoCA=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240719153055-607eba001f65 h1:p9PIsp5RyrLdlOR7MXyeGBx04v3+1IMEEBBV22fJZPo=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240719153055-607eba001f65/go.mod h1:oPdUxLy6TFeRxiRC/BoNb3YUNcnSiOnJrzFTnCPSoCA=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240720114704-037fc8a18c60 h1:cy58ybsaMHX8lVoCa3bsWkwQGxD4sPmMAMsVYg42kqU=
|
||||
git.solsynth.dev/hydrogen/dealer v0.0.0-20240720114704-037fc8a18c60/go.mod h1:oPdUxLy6TFeRxiRC/BoNb3YUNcnSiOnJrzFTnCPSoCA=
|
||||
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745 h1:40BUsQMNXjqHyytkyF9py1HjTAWlRgO6R57YXUrHNy4=
|
||||
git.solsynth.dev/hydrogen/paperclip v0.0.0-20240622051057-0f56dba45745/go.mod h1:FsQGSLTl0gvo+9Jmbot02S72suyF9tFTrzDj70Xhifo=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
|
@ -1,20 +1,22 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"google.golang.org/grpc/reflection"
|
||||
"net"
|
||||
|
||||
"google.golang.org/grpc/reflection"
|
||||
|
||||
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
import health "google.golang.org/grpc/health/grpc_health_v1"
|
||||
health "google.golang.org/grpc/health/grpc_health_v1"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
proto.UnimplementedAuthServer
|
||||
proto.UnimplementedNotifierServer
|
||||
proto.UnimplementedRealmServer
|
||||
proto.UnimplementedStreamControllerServer
|
||||
health.UnimplementedHealthServer
|
||||
|
||||
srv *grpc.Server
|
||||
@ -28,6 +30,7 @@ func NewServer() *Server {
|
||||
proto.RegisterAuthServer(server.srv, server)
|
||||
proto.RegisterNotifierServer(server.srv, server)
|
||||
proto.RegisterRealmServer(server.srv, server)
|
||||
proto.RegisterStreamControllerServer(server.srv, server)
|
||||
health.RegisterHealthServer(server.srv, server)
|
||||
|
||||
reflection.Register(server.srv)
|
||||
|
21
pkg/internal/grpc/stream.go
Normal file
21
pkg/internal/grpc/stream.go
Normal file
@ -0,0 +1,21 @@
|
||||
package grpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
|
||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||
)
|
||||
|
||||
func (v *Server) EmitStreamEvent(ctx context.Context, request *proto.StreamEventRequest) (*proto.StreamEventResponse, error) {
|
||||
switch request.GetEvent() {
|
||||
case "ClientRegister":
|
||||
// No longer need update user online status
|
||||
// Based on realtime sever connection status
|
||||
break
|
||||
case "ClientUnregister":
|
||||
// Update user last seen at
|
||||
_ = services.SetAccountLastSeen(uint(request.GetUserId()))
|
||||
}
|
||||
|
||||
return &proto.StreamEventResponse{}, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user