forked from heroiclabs/nakama
/
runtime.go
3028 lines (2795 loc) · 196 KB
/
runtime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2018 The Nakama Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package server
import (
"context"
"database/sql"
"errors"
"os"
"path/filepath"
"strings"
"sync"
"time"
"github.com/gofrs/uuid"
"github.com/talktonpc/nakama-common/api"
"github.com/talktonpc/nakama-common/rtapi"
"github.com/talktonpc/nakama-common/runtime"
"github.com/talktonpc/nakama/v3/social"
"go.uber.org/atomic"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/encoding/protojson"
)
var (
ErrRuntimeRPCNotFound = errors.New("RPC function not found")
)
const API_PREFIX = "/nakama.api.Nakama/"
const RTAPI_PREFIX = "*rtapi.Envelope_"
var API_PREFIX_LOWERCASE = strings.ToLower(API_PREFIX)
var RTAPI_PREFIX_LOWERCASE = strings.ToLower(RTAPI_PREFIX)
type (
RuntimeRpcFunction func(ctx context.Context, headers, queryParams map[string][]string, userID, username string, vars map[string]string, expiry int64, sessionID, clientIP, clientPort, lang, payload string) (string, error, codes.Code)
RuntimeBeforeRtFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, sessionID, clientIP, clientPort, lang string, envelope *rtapi.Envelope) (*rtapi.Envelope, error)
RuntimeAfterRtFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, sessionID, clientIP, clientPort, lang string, envelope *rtapi.Envelope) error
RuntimeBeforeGetAccountFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string) (error, codes.Code)
RuntimeAfterGetAccountFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Account) error
RuntimeBeforeUpdateAccountFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.UpdateAccountRequest) (*api.UpdateAccountRequest, error, codes.Code)
RuntimeAfterUpdateAccountFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.UpdateAccountRequest) error
RuntimeBeforeSessionRefreshFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.SessionRefreshRequest) (*api.SessionRefreshRequest, error, codes.Code)
RuntimeAfterSessionRefreshFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.SessionRefreshRequest) error
RuntimeBeforeSessionLogoutFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.SessionLogoutRequest) (*api.SessionLogoutRequest, error, codes.Code)
RuntimeAfterSessionLogoutFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.SessionLogoutRequest) error
RuntimeBeforeAuthenticateAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateAppleRequest) (*api.AuthenticateAppleRequest, error, codes.Code)
RuntimeAfterAuthenticateAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateAppleRequest) error
RuntimeBeforeAuthenticateCustomFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateCustomRequest) (*api.AuthenticateCustomRequest, error, codes.Code)
RuntimeAfterAuthenticateCustomFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateCustomRequest) error
RuntimeBeforeAuthenticateDeviceFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateDeviceRequest) (*api.AuthenticateDeviceRequest, error, codes.Code)
RuntimeAfterAuthenticateDeviceFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateDeviceRequest) error
RuntimeBeforeAuthenticateEmailFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateEmailRequest) (*api.AuthenticateEmailRequest, error, codes.Code)
RuntimeAfterAuthenticateEmailFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateEmailRequest) error
RuntimeBeforeAuthenticateFacebookFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateFacebookRequest) (*api.AuthenticateFacebookRequest, error, codes.Code)
RuntimeAfterAuthenticateFacebookFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateFacebookRequest) error
RuntimeBeforeAuthenticateFacebookInstantGameFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateFacebookInstantGameRequest) (*api.AuthenticateFacebookInstantGameRequest, error, codes.Code)
RuntimeAfterAuthenticateFacebookInstantGameFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateFacebookInstantGameRequest) error
RuntimeBeforeAuthenticateGameCenterFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateGameCenterRequest) (*api.AuthenticateGameCenterRequest, error, codes.Code)
RuntimeAfterAuthenticateGameCenterFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateGameCenterRequest) error
RuntimeBeforeAuthenticateGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateGoogleRequest) (*api.AuthenticateGoogleRequest, error, codes.Code)
RuntimeAfterAuthenticateGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateGoogleRequest) error
RuntimeBeforeAuthenticateSteamFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AuthenticateSteamRequest) (*api.AuthenticateSteamRequest, error, codes.Code)
RuntimeAfterAuthenticateSteamFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Session, in *api.AuthenticateSteamRequest) error
RuntimeBeforeListChannelMessagesFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListChannelMessagesRequest) (*api.ListChannelMessagesRequest, error, codes.Code)
RuntimeAfterListChannelMessagesFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.ChannelMessageList, in *api.ListChannelMessagesRequest) error
RuntimeBeforeListFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListFriendsRequest) (*api.ListFriendsRequest, error, codes.Code)
RuntimeAfterListFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.FriendList) error
RuntimeBeforeAddFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AddFriendsRequest) (*api.AddFriendsRequest, error, codes.Code)
RuntimeAfterAddFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AddFriendsRequest) error
RuntimeBeforeDeleteFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteFriendsRequest) (*api.DeleteFriendsRequest, error, codes.Code)
RuntimeAfterDeleteFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteFriendsRequest) error
RuntimeBeforeBlockFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.BlockFriendsRequest) (*api.BlockFriendsRequest, error, codes.Code)
RuntimeAfterBlockFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.BlockFriendsRequest) error
RuntimeBeforeImportFacebookFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ImportFacebookFriendsRequest) (*api.ImportFacebookFriendsRequest, error, codes.Code)
RuntimeAfterImportFacebookFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ImportFacebookFriendsRequest) error
RuntimeBeforeImportSteamFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ImportSteamFriendsRequest) (*api.ImportSteamFriendsRequest, error, codes.Code)
RuntimeAfterImportSteamFriendsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ImportSteamFriendsRequest) error
RuntimeBeforeCreateGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.CreateGroupRequest) (*api.CreateGroupRequest, error, codes.Code)
RuntimeAfterCreateGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Group, in *api.CreateGroupRequest) error
RuntimeBeforeUpdateGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.UpdateGroupRequest) (*api.UpdateGroupRequest, error, codes.Code)
RuntimeAfterUpdateGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.UpdateGroupRequest) error
RuntimeBeforeDeleteGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteGroupRequest) (*api.DeleteGroupRequest, error, codes.Code)
RuntimeAfterDeleteGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteGroupRequest) error
RuntimeBeforeJoinGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.JoinGroupRequest) (*api.JoinGroupRequest, error, codes.Code)
RuntimeAfterJoinGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.JoinGroupRequest) error
RuntimeBeforeLeaveGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.LeaveGroupRequest) (*api.LeaveGroupRequest, error, codes.Code)
RuntimeAfterLeaveGroupFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.LeaveGroupRequest) error
RuntimeBeforeAddGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AddGroupUsersRequest) (*api.AddGroupUsersRequest, error, codes.Code)
RuntimeAfterAddGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AddGroupUsersRequest) error
RuntimeBeforeBanGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.BanGroupUsersRequest) (*api.BanGroupUsersRequest, error, codes.Code)
RuntimeAfterBanGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.BanGroupUsersRequest) error
RuntimeBeforeKickGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.KickGroupUsersRequest) (*api.KickGroupUsersRequest, error, codes.Code)
RuntimeAfterKickGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.KickGroupUsersRequest) error
RuntimeBeforePromoteGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.PromoteGroupUsersRequest) (*api.PromoteGroupUsersRequest, error, codes.Code)
RuntimeAfterPromoteGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.PromoteGroupUsersRequest) error
RuntimeBeforeDemoteGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DemoteGroupUsersRequest) (*api.DemoteGroupUsersRequest, error, codes.Code)
RuntimeAfterDemoteGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DemoteGroupUsersRequest) error
RuntimeBeforeListGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListGroupUsersRequest) (*api.ListGroupUsersRequest, error, codes.Code)
RuntimeAfterListGroupUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.GroupUserList, in *api.ListGroupUsersRequest) error
RuntimeBeforeListUserGroupsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListUserGroupsRequest) (*api.ListUserGroupsRequest, error, codes.Code)
RuntimeAfterListUserGroupsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.UserGroupList, in *api.ListUserGroupsRequest) error
RuntimeBeforeListGroupsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListGroupsRequest) (*api.ListGroupsRequest, error, codes.Code)
RuntimeAfterListGroupsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.GroupList, in *api.ListGroupsRequest) error
RuntimeBeforeDeleteLeaderboardRecordFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteLeaderboardRecordRequest) (*api.DeleteLeaderboardRecordRequest, error, codes.Code)
RuntimeAfterDeleteLeaderboardRecordFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteLeaderboardRecordRequest) error
RuntimeBeforeListLeaderboardRecordsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListLeaderboardRecordsRequest) (*api.ListLeaderboardRecordsRequest, error, codes.Code)
RuntimeAfterListLeaderboardRecordsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.LeaderboardRecordList, in *api.ListLeaderboardRecordsRequest) error
RuntimeBeforeWriteLeaderboardRecordFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.WriteLeaderboardRecordRequest) (*api.WriteLeaderboardRecordRequest, error, codes.Code)
RuntimeAfterWriteLeaderboardRecordFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.LeaderboardRecord, in *api.WriteLeaderboardRecordRequest) error
RuntimeBeforeListLeaderboardRecordsAroundOwnerFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListLeaderboardRecordsAroundOwnerRequest) (*api.ListLeaderboardRecordsAroundOwnerRequest, error, codes.Code)
RuntimeAfterListLeaderboardRecordsAroundOwnerFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.LeaderboardRecordList, in *api.ListLeaderboardRecordsAroundOwnerRequest) error
RuntimeBeforeLinkAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountApple) (*api.AccountApple, error, codes.Code)
RuntimeAfterLinkAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountApple) error
RuntimeBeforeLinkCustomFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountCustom) (*api.AccountCustom, error, codes.Code)
RuntimeAfterLinkCustomFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountCustom) error
RuntimeBeforeLinkDeviceFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountDevice) (*api.AccountDevice, error, codes.Code)
RuntimeAfterLinkDeviceFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountDevice) error
RuntimeBeforeLinkEmailFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountEmail) (*api.AccountEmail, error, codes.Code)
RuntimeAfterLinkEmailFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountEmail) error
RuntimeBeforeLinkFacebookFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.LinkFacebookRequest) (*api.LinkFacebookRequest, error, codes.Code)
RuntimeAfterLinkFacebookFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.LinkFacebookRequest) error
RuntimeBeforeLinkFacebookInstantGameFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountFacebookInstantGame) (*api.AccountFacebookInstantGame, error, codes.Code)
RuntimeAfterLinkFacebookInstantGameFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountFacebookInstantGame) error
RuntimeBeforeLinkGameCenterFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGameCenter) (*api.AccountGameCenter, error, codes.Code)
RuntimeAfterLinkGameCenterFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGameCenter) error
RuntimeBeforeLinkGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGoogle) (*api.AccountGoogle, error, codes.Code)
RuntimeAfterLinkGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGoogle) error
RuntimeBeforeLinkSteamFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.LinkSteamRequest) (*api.LinkSteamRequest, error, codes.Code)
RuntimeAfterLinkSteamFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.LinkSteamRequest) error
RuntimeBeforeListMatchesFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListMatchesRequest) (*api.ListMatchesRequest, error, codes.Code)
RuntimeAfterListMatchesFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.MatchList, in *api.ListMatchesRequest) error
RuntimeBeforeListNotificationsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListNotificationsRequest) (*api.ListNotificationsRequest, error, codes.Code)
RuntimeAfterListNotificationsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.NotificationList, in *api.ListNotificationsRequest) error
RuntimeBeforeDeleteNotificationFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteNotificationsRequest) (*api.DeleteNotificationsRequest, error, codes.Code)
RuntimeAfterDeleteNotificationFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteNotificationsRequest) error
RuntimeBeforeListStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListStorageObjectsRequest) (*api.ListStorageObjectsRequest, error, codes.Code)
RuntimeAfterListStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.StorageObjectList, in *api.ListStorageObjectsRequest) error
RuntimeBeforeReadStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ReadStorageObjectsRequest) (*api.ReadStorageObjectsRequest, error, codes.Code)
RuntimeAfterReadStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.StorageObjects, in *api.ReadStorageObjectsRequest) error
RuntimeBeforeWriteStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.WriteStorageObjectsRequest) (*api.WriteStorageObjectsRequest, error, codes.Code)
RuntimeAfterWriteStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.StorageObjectAcks, in *api.WriteStorageObjectsRequest) error
RuntimeBeforeDeleteStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteStorageObjectsRequest) (*api.DeleteStorageObjectsRequest, error, codes.Code)
RuntimeAfterDeleteStorageObjectsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.DeleteStorageObjectsRequest) error
RuntimeBeforeJoinTournamentFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.JoinTournamentRequest) (*api.JoinTournamentRequest, error, codes.Code)
RuntimeAfterJoinTournamentFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.JoinTournamentRequest) error
RuntimeBeforeListTournamentRecordsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListTournamentRecordsRequest) (*api.ListTournamentRecordsRequest, error, codes.Code)
RuntimeAfterListTournamentRecordsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.TournamentRecordList, in *api.ListTournamentRecordsRequest) error
RuntimeBeforeListTournamentsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListTournamentsRequest) (*api.ListTournamentsRequest, error, codes.Code)
RuntimeAfterListTournamentsFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.TournamentList, in *api.ListTournamentsRequest) error
RuntimeBeforeWriteTournamentRecordFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.WriteTournamentRecordRequest) (*api.WriteTournamentRecordRequest, error, codes.Code)
RuntimeAfterWriteTournamentRecordFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.LeaderboardRecord, in *api.WriteTournamentRecordRequest) error
RuntimeBeforeListTournamentRecordsAroundOwnerFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ListTournamentRecordsAroundOwnerRequest) (*api.ListTournamentRecordsAroundOwnerRequest, error, codes.Code)
RuntimeAfterListTournamentRecordsAroundOwnerFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.TournamentRecordList, in *api.ListTournamentRecordsAroundOwnerRequest) error
RuntimeBeforeUnlinkAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountApple) (*api.AccountApple, error, codes.Code)
RuntimeAfterUnlinkAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountApple) error
RuntimeBeforeUnlinkCustomFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountCustom) (*api.AccountCustom, error, codes.Code)
RuntimeAfterUnlinkCustomFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountCustom) error
RuntimeBeforeUnlinkDeviceFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountDevice) (*api.AccountDevice, error, codes.Code)
RuntimeAfterUnlinkDeviceFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountDevice) error
RuntimeBeforeUnlinkEmailFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountEmail) (*api.AccountEmail, error, codes.Code)
RuntimeAfterUnlinkEmailFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountEmail) error
RuntimeBeforeUnlinkFacebookFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountFacebook) (*api.AccountFacebook, error, codes.Code)
RuntimeAfterUnlinkFacebookFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountFacebook) error
RuntimeBeforeUnlinkFacebookInstantGameFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountFacebookInstantGame) (*api.AccountFacebookInstantGame, error, codes.Code)
RuntimeAfterUnlinkFacebookInstantGameFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountFacebookInstantGame) error
RuntimeBeforeUnlinkGameCenterFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGameCenter) (*api.AccountGameCenter, error, codes.Code)
RuntimeAfterUnlinkGameCenterFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGameCenter) error
RuntimeBeforeUnlinkGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGoogle) (*api.AccountGoogle, error, codes.Code)
RuntimeAfterUnlinkGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountGoogle) error
RuntimeBeforeUnlinkSteamFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountSteam) (*api.AccountSteam, error, codes.Code)
RuntimeAfterUnlinkSteamFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.AccountSteam) error
RuntimeBeforeGetUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.GetUsersRequest) (*api.GetUsersRequest, error, codes.Code)
RuntimeAfterGetUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.Users, in *api.GetUsersRequest) error
RuntimeBeforeEventFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.Event) (*api.Event, error, codes.Code)
RuntimeAfterEventFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.Event) error
RuntimeBeforeValidatePurchaseAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ValidatePurchaseAppleRequest) (*api.ValidatePurchaseAppleRequest, error, codes.Code)
RuntimeAfterValidatePurchaseAppleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.ValidatePurchaseResponse, in *api.ValidatePurchaseAppleRequest) error
RuntimeBeforeValidatePurchaseGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ValidatePurchaseGoogleRequest) (*api.ValidatePurchaseGoogleRequest, error, codes.Code)
RuntimeAfterValidatePurchaseGoogleFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.ValidatePurchaseResponse, in *api.ValidatePurchaseGoogleRequest) error
RuntimeBeforeValidatePurchaseHuaweiFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, in *api.ValidatePurchaseHuaweiRequest) (*api.ValidatePurchaseHuaweiRequest, error, codes.Code)
RuntimeAfterValidatePurchaseHuaweiFunction func(ctx context.Context, logger *zap.Logger, userID, username string, vars map[string]string, expiry int64, clientIP, clientPort string, out *api.ValidatePurchaseResponse, in *api.ValidatePurchaseHuaweiRequest) error
RuntimeMatchmakerMatchedFunction func(ctx context.Context, entries []*MatchmakerEntry) (string, bool, error)
RuntimeMatchCreateFunction func(ctx context.Context, logger *zap.Logger, id uuid.UUID, node string, stopped *atomic.Bool, name string) (RuntimeMatchCore, error)
RuntimeMatchDeferMessageFunction func(msg *DeferredMessage) error
RuntimeTournamentEndFunction func(ctx context.Context, tournament *api.Tournament, end, reset int64) error
RuntimeTournamentResetFunction func(ctx context.Context, tournament *api.Tournament, end, reset int64) error
RuntimeLeaderboardResetFunction func(ctx context.Context, leaderboard *api.Leaderboard, reset int64) error
RuntimeEventFunction func(ctx context.Context, logger runtime.Logger, evt *api.Event)
RuntimeEventCustomFunction func(ctx context.Context, evt *api.Event)
RuntimeEventSessionStartFunction func(userID, username string, vars map[string]string, expiry int64, sessionID, clientIP, clientPort, lang string, evtTimeSec int64)
RuntimeEventSessionEndFunction func(userID, username string, vars map[string]string, expiry int64, sessionID, clientIP, clientPort, lang string, evtTimeSec int64, reason string)
)
type RuntimeExecutionMode int
const (
RuntimeExecutionModeEvent RuntimeExecutionMode = iota
RuntimeExecutionModeRunOnce
RuntimeExecutionModeRPC
RuntimeExecutionModeBefore
RuntimeExecutionModeAfter
RuntimeExecutionModeMatch
RuntimeExecutionModeMatchmaker
RuntimeExecutionModeMatchCreate
RuntimeExecutionModeTournamentEnd
RuntimeExecutionModeTournamentReset
RuntimeExecutionModeLeaderboardReset
)
func (e RuntimeExecutionMode) String() string {
switch e {
case RuntimeExecutionModeEvent:
return "event"
case RuntimeExecutionModeRunOnce:
return "run_once"
case RuntimeExecutionModeRPC:
return "rpc"
case RuntimeExecutionModeBefore:
return "before"
case RuntimeExecutionModeAfter:
return "after"
case RuntimeExecutionModeMatch:
return "match"
case RuntimeExecutionModeMatchmaker:
return "matchmaker"
case RuntimeExecutionModeMatchCreate:
return "match_create"
case RuntimeExecutionModeTournamentEnd:
return "tournament_end"
case RuntimeExecutionModeTournamentReset:
return "tournament_reset"
case RuntimeExecutionModeLeaderboardReset:
return "leaderboard_reset"
}
return ""
}
type RuntimeMatchCore interface {
MatchInit(presenceList *MatchPresenceList, deferMessageFn RuntimeMatchDeferMessageFunction, params map[string]interface{}) (interface{}, int, error)
MatchJoinAttempt(tick int64, state interface{}, userID, sessionID uuid.UUID, username string, sessionExpiry int64, vars map[string]string, clientIP, clientPort, node string, metadata map[string]string) (interface{}, bool, string, error)
MatchJoin(tick int64, state interface{}, joins []*MatchPresence) (interface{}, error)
MatchLeave(tick int64, state interface{}, leaves []*MatchPresence) (interface{}, error)
MatchLoop(tick int64, state interface{}, inputCh <-chan *MatchDataMessage) (interface{}, error)
MatchTerminate(tick int64, state interface{}, graceSeconds int) (interface{}, error)
MatchSignal(tick int64, state interface{}, data string) (interface{}, string, error)
GetState(state interface{}) (string, error)
Label() string
TickRate() int
HandlerName() string
CreateTime() int64
Cancel()
Cleanup()
}
type RuntimeEventFunctions struct {
sessionStartFunction RuntimeEventSessionStartFunction
sessionEndFunction RuntimeEventSessionEndFunction
eventFunction RuntimeEventCustomFunction
}
type moduleInfo struct {
path string
modTime time.Time
}
type RuntimeInfo struct {
GoRpcFunctions []string
LuaRpcFunctions []string
JavaScriptRpcFunctions []string
GoModules []*moduleInfo
LuaModules []*moduleInfo
JavaScriptModules []*moduleInfo
}
type RuntimeBeforeReqFunctions struct {
beforeGetAccountFunction RuntimeBeforeGetAccountFunction
beforeUpdateAccountFunction RuntimeBeforeUpdateAccountFunction
beforeSessionRefreshFunction RuntimeBeforeSessionRefreshFunction
beforeSessionLogoutFunction RuntimeBeforeSessionLogoutFunction
beforeAuthenticateAppleFunction RuntimeBeforeAuthenticateAppleFunction
beforeAuthenticateCustomFunction RuntimeBeforeAuthenticateCustomFunction
beforeAuthenticateDeviceFunction RuntimeBeforeAuthenticateDeviceFunction
beforeAuthenticateEmailFunction RuntimeBeforeAuthenticateEmailFunction
beforeAuthenticateFacebookFunction RuntimeBeforeAuthenticateFacebookFunction
beforeAuthenticateFacebookInstantGameFunction RuntimeBeforeAuthenticateFacebookInstantGameFunction
beforeAuthenticateGameCenterFunction RuntimeBeforeAuthenticateGameCenterFunction
beforeAuthenticateGoogleFunction RuntimeBeforeAuthenticateGoogleFunction
beforeAuthenticateSteamFunction RuntimeBeforeAuthenticateSteamFunction
beforeListChannelMessagesFunction RuntimeBeforeListChannelMessagesFunction
beforeListFriendsFunction RuntimeBeforeListFriendsFunction
beforeAddFriendsFunction RuntimeBeforeAddFriendsFunction
beforeDeleteFriendsFunction RuntimeBeforeDeleteFriendsFunction
beforeBlockFriendsFunction RuntimeBeforeBlockFriendsFunction
beforeImportFacebookFriendsFunction RuntimeBeforeImportFacebookFriendsFunction
beforeImportSteamFriendsFunction RuntimeBeforeImportSteamFriendsFunction
beforeCreateGroupFunction RuntimeBeforeCreateGroupFunction
beforeUpdateGroupFunction RuntimeBeforeUpdateGroupFunction
beforeDeleteGroupFunction RuntimeBeforeDeleteGroupFunction
beforeJoinGroupFunction RuntimeBeforeJoinGroupFunction
beforeLeaveGroupFunction RuntimeBeforeLeaveGroupFunction
beforeAddGroupUsersFunction RuntimeBeforeAddGroupUsersFunction
beforeBanGroupUsersFunction RuntimeBeforeBanGroupUsersFunction
beforeKickGroupUsersFunction RuntimeBeforeKickGroupUsersFunction
beforePromoteGroupUsersFunction RuntimeBeforePromoteGroupUsersFunction
beforeDemoteGroupUsersFunction RuntimeBeforeDemoteGroupUsersFunction
beforeListGroupUsersFunction RuntimeBeforeListGroupUsersFunction
beforeListUserGroupsFunction RuntimeBeforeListUserGroupsFunction
beforeListGroupsFunction RuntimeBeforeListGroupsFunction
beforeDeleteLeaderboardRecordFunction RuntimeBeforeDeleteLeaderboardRecordFunction
beforeListLeaderboardRecordsFunction RuntimeBeforeListLeaderboardRecordsFunction
beforeWriteLeaderboardRecordFunction RuntimeBeforeWriteLeaderboardRecordFunction
beforeListLeaderboardRecordsAroundOwnerFunction RuntimeBeforeListLeaderboardRecordsAroundOwnerFunction
beforeLinkAppleFunction RuntimeBeforeLinkAppleFunction
beforeLinkCustomFunction RuntimeBeforeLinkCustomFunction
beforeLinkDeviceFunction RuntimeBeforeLinkDeviceFunction
beforeLinkEmailFunction RuntimeBeforeLinkEmailFunction
beforeLinkFacebookFunction RuntimeBeforeLinkFacebookFunction
beforeLinkFacebookInstantGameFunction RuntimeBeforeLinkFacebookInstantGameFunction
beforeLinkGameCenterFunction RuntimeBeforeLinkGameCenterFunction
beforeLinkGoogleFunction RuntimeBeforeLinkGoogleFunction
beforeLinkSteamFunction RuntimeBeforeLinkSteamFunction
beforeListMatchesFunction RuntimeBeforeListMatchesFunction
beforeListNotificationsFunction RuntimeBeforeListNotificationsFunction
beforeDeleteNotificationFunction RuntimeBeforeDeleteNotificationFunction
beforeListStorageObjectsFunction RuntimeBeforeListStorageObjectsFunction
beforeReadStorageObjectsFunction RuntimeBeforeReadStorageObjectsFunction
beforeWriteStorageObjectsFunction RuntimeBeforeWriteStorageObjectsFunction
beforeDeleteStorageObjectsFunction RuntimeBeforeDeleteStorageObjectsFunction
beforeJoinTournamentFunction RuntimeBeforeJoinTournamentFunction
beforeListTournamentRecordsFunction RuntimeBeforeListTournamentRecordsFunction
beforeListTournamentsFunction RuntimeBeforeListTournamentsFunction
beforeWriteTournamentRecordFunction RuntimeBeforeWriteTournamentRecordFunction
beforeListTournamentRecordsAroundOwnerFunction RuntimeBeforeListTournamentRecordsAroundOwnerFunction
beforeUnlinkAppleFunction RuntimeBeforeUnlinkAppleFunction
beforeUnlinkCustomFunction RuntimeBeforeUnlinkCustomFunction
beforeUnlinkDeviceFunction RuntimeBeforeUnlinkDeviceFunction
beforeUnlinkEmailFunction RuntimeBeforeUnlinkEmailFunction
beforeUnlinkFacebookFunction RuntimeBeforeUnlinkFacebookFunction
beforeUnlinkFacebookInstantGameFunction RuntimeBeforeUnlinkFacebookInstantGameFunction
beforeUnlinkGameCenterFunction RuntimeBeforeUnlinkGameCenterFunction
beforeUnlinkGoogleFunction RuntimeBeforeUnlinkGoogleFunction
beforeUnlinkSteamFunction RuntimeBeforeUnlinkSteamFunction
beforeGetUsersFunction RuntimeBeforeGetUsersFunction
beforeEventFunction RuntimeBeforeEventFunction
beforeValidatePurchaseAppleFunction RuntimeBeforeValidatePurchaseAppleFunction
beforeValidatePurchaseGoogleFunction RuntimeBeforeValidatePurchaseGoogleFunction
beforeValidatePurchaseHuaweiFunction RuntimeBeforeValidatePurchaseHuaweiFunction
}
type RuntimeAfterReqFunctions struct {
afterGetAccountFunction RuntimeAfterGetAccountFunction
afterUpdateAccountFunction RuntimeAfterUpdateAccountFunction
afterSessionRefreshFunction RuntimeAfterSessionRefreshFunction
afterSessionLogoutFunction RuntimeAfterSessionLogoutFunction
afterAuthenticateAppleFunction RuntimeAfterAuthenticateAppleFunction
afterAuthenticateCustomFunction RuntimeAfterAuthenticateCustomFunction
afterAuthenticateDeviceFunction RuntimeAfterAuthenticateDeviceFunction
afterAuthenticateEmailFunction RuntimeAfterAuthenticateEmailFunction
afterAuthenticateFacebookFunction RuntimeAfterAuthenticateFacebookFunction
afterAuthenticateFacebookInstantGameFunction RuntimeAfterAuthenticateFacebookInstantGameFunction
afterAuthenticateGameCenterFunction RuntimeAfterAuthenticateGameCenterFunction
afterAuthenticateGoogleFunction RuntimeAfterAuthenticateGoogleFunction
afterAuthenticateSteamFunction RuntimeAfterAuthenticateSteamFunction
afterListChannelMessagesFunction RuntimeAfterListChannelMessagesFunction
afterListFriendsFunction RuntimeAfterListFriendsFunction
afterAddFriendsFunction RuntimeAfterAddFriendsFunction
afterDeleteFriendsFunction RuntimeAfterDeleteFriendsFunction
afterBlockFriendsFunction RuntimeAfterBlockFriendsFunction
afterImportFacebookFriendsFunction RuntimeAfterImportFacebookFriendsFunction
afterImportSteamFriendsFunction RuntimeAfterImportSteamFriendsFunction
afterCreateGroupFunction RuntimeAfterCreateGroupFunction
afterUpdateGroupFunction RuntimeAfterUpdateGroupFunction
afterDeleteGroupFunction RuntimeAfterDeleteGroupFunction
afterJoinGroupFunction RuntimeAfterJoinGroupFunction
afterLeaveGroupFunction RuntimeAfterLeaveGroupFunction
afterAddGroupUsersFunction RuntimeAfterAddGroupUsersFunction
afterBanGroupUsersFunction RuntimeAfterBanGroupUsersFunction
afterKickGroupUsersFunction RuntimeAfterKickGroupUsersFunction
afterPromoteGroupUsersFunction RuntimeAfterPromoteGroupUsersFunction
afterDemoteGroupUsersFunction RuntimeAfterDemoteGroupUsersFunction
afterListGroupUsersFunction RuntimeAfterListGroupUsersFunction
afterListUserGroupsFunction RuntimeAfterListUserGroupsFunction
afterListGroupsFunction RuntimeAfterListGroupsFunction
afterDeleteLeaderboardRecordFunction RuntimeAfterDeleteLeaderboardRecordFunction
afterListLeaderboardRecordsFunction RuntimeAfterListLeaderboardRecordsFunction
afterWriteLeaderboardRecordFunction RuntimeAfterWriteLeaderboardRecordFunction
afterListLeaderboardRecordsAroundOwnerFunction RuntimeAfterListLeaderboardRecordsAroundOwnerFunction
afterLinkAppleFunction RuntimeAfterLinkAppleFunction
afterLinkCustomFunction RuntimeAfterLinkCustomFunction
afterLinkDeviceFunction RuntimeAfterLinkDeviceFunction
afterLinkEmailFunction RuntimeAfterLinkEmailFunction
afterLinkFacebookFunction RuntimeAfterLinkFacebookFunction
afterLinkFacebookInstantGameFunction RuntimeAfterLinkFacebookInstantGameFunction
afterLinkGameCenterFunction RuntimeAfterLinkGameCenterFunction
afterLinkGoogleFunction RuntimeAfterLinkGoogleFunction
afterLinkSteamFunction RuntimeAfterLinkSteamFunction
afterListMatchesFunction RuntimeAfterListMatchesFunction
afterListNotificationsFunction RuntimeAfterListNotificationsFunction
afterDeleteNotificationFunction RuntimeAfterDeleteNotificationFunction
afterListStorageObjectsFunction RuntimeAfterListStorageObjectsFunction
afterReadStorageObjectsFunction RuntimeAfterReadStorageObjectsFunction
afterWriteStorageObjectsFunction RuntimeAfterWriteStorageObjectsFunction
afterDeleteStorageObjectsFunction RuntimeAfterDeleteStorageObjectsFunction
afterJoinTournamentFunction RuntimeAfterJoinTournamentFunction
afterListTournamentRecordsFunction RuntimeAfterListTournamentRecordsFunction
afterListTournamentsFunction RuntimeAfterListTournamentsFunction
afterWriteTournamentRecordFunction RuntimeAfterWriteTournamentRecordFunction
afterListTournamentRecordsAroundOwnerFunction RuntimeAfterListTournamentRecordsAroundOwnerFunction
afterUnlinkAppleFunction RuntimeAfterUnlinkAppleFunction
afterUnlinkCustomFunction RuntimeAfterUnlinkCustomFunction
afterUnlinkDeviceFunction RuntimeAfterUnlinkDeviceFunction
afterUnlinkEmailFunction RuntimeAfterUnlinkEmailFunction
afterUnlinkFacebookFunction RuntimeAfterUnlinkFacebookFunction
afterUnlinkFacebookInstantGameFunction RuntimeAfterUnlinkFacebookInstantGameFunction
afterUnlinkGameCenterFunction RuntimeAfterUnlinkGameCenterFunction
afterUnlinkGoogleFunction RuntimeAfterUnlinkGoogleFunction
afterUnlinkSteamFunction RuntimeAfterUnlinkSteamFunction
afterGetUsersFunction RuntimeAfterGetUsersFunction
afterEventFunction RuntimeAfterEventFunction
afterValidatePurchaseAppleFunction RuntimeAfterValidatePurchaseAppleFunction
afterValidatePurchaseGoogleFunction RuntimeAfterValidatePurchaseGoogleFunction
afterValidatePurchaseHuaweiFunction RuntimeAfterValidatePurchaseHuaweiFunction
}
type Runtime struct {
matchCreateFunction RuntimeMatchCreateFunction
rpcFunctions map[string]RuntimeRpcFunction
beforeRtFunctions map[string]RuntimeBeforeRtFunction
afterRtFunctions map[string]RuntimeAfterRtFunction
beforeReqFunctions *RuntimeBeforeReqFunctions
afterReqFunctions *RuntimeAfterReqFunctions
matchmakerMatchedFunction RuntimeMatchmakerMatchedFunction
tournamentEndFunction RuntimeTournamentEndFunction
tournamentResetFunction RuntimeTournamentResetFunction
leaderboardResetFunction RuntimeLeaderboardResetFunction
eventFunctions *RuntimeEventFunctions
consoleInfo *RuntimeInfo
}
type MatchNamesListFunction func() []string
type MatchProvider struct {
sync.RWMutex
providers []RuntimeMatchCreateFunction
providerNames []string
}
func (mp *MatchProvider) RegisterCreateFn(name string, fn RuntimeMatchCreateFunction) {
mp.Lock()
newProviders := make([]RuntimeMatchCreateFunction, len(mp.providers)+1, len(mp.providers)+1)
copy(newProviders, mp.providers)
newProviders[len(mp.providers)] = fn
mp.providers = newProviders
newProviderNames := make([]string, len(mp.providerNames)+1, len(mp.providerNames)+1)
copy(newProviderNames, mp.providerNames)
newProviderNames[len(mp.providerNames)] = name
mp.providerNames = newProviderNames
mp.Unlock()
}
func (mp *MatchProvider) CreateMatch(ctx context.Context, logger *zap.Logger, id uuid.UUID, node string, stopped *atomic.Bool, name string) (RuntimeMatchCore, error) {
mp.RLock()
providers := mp.providers
mp.RUnlock()
for _, p := range providers {
core, err := p(ctx, logger, id, node, stopped, name)
if err != nil {
return nil, err
}
if core != nil {
return core, nil
}
}
return nil, nil
}
func NewMatchProvider() *MatchProvider {
return &MatchProvider{
providers: make([]RuntimeMatchCreateFunction, 0),
providerNames: make([]string, 0),
}
}
func GetRuntimePaths(logger *zap.Logger, rootPath string) ([]string, error) {
if err := os.MkdirAll(rootPath, os.ModePerm); err != nil {
return nil, err
}
paths := make([]string, 0, 5)
if err := filepath.Walk(rootPath, func(path string, f os.FileInfo, err error) error {
if err != nil {
logger.Error("Error listing runtime path", zap.String("path", path), zap.Error(err))
return err
}
// Ignore directories.
if !f.IsDir() {
paths = append(paths, path)
}
return nil
}); err != nil {
logger.Error("Failed to list runtime path", zap.Error(err))
return nil, err
}
return paths, nil
}
func CheckRuntime(logger *zap.Logger, config Config) error {
// Get all paths inside the configured runtime.
paths, err := GetRuntimePaths(logger, config.GetRuntime().Path)
if err != nil {
return err
}
// Check any Go runtime modules.
err = CheckRuntimeProviderGo(logger, config.GetRuntime().Path, paths)
if err != nil {
return err
}
// Check any Lua runtime modules.
err = CheckRuntimeProviderLua(logger, config, paths)
if err != nil {
return err
}
// Check any JavaScript runtime modules.
err = CheckRuntimeProviderJavascript(logger, config)
if err != nil {
return err
}
return nil
}
func NewRuntime(ctx context.Context, logger, startupLogger *zap.Logger, db *sql.DB, protojsonMarshaler *protojson.MarshalOptions, protojsonUnmarshaler *protojson.UnmarshalOptions, config Config, socialClient *social.Client, leaderboardCache LeaderboardCache, leaderboardRankCache LeaderboardRankCache, leaderboardScheduler LeaderboardScheduler, sessionRegistry SessionRegistry, sessionCache SessionCache, matchRegistry MatchRegistry, tracker Tracker, metrics Metrics, streamManager StreamManager, router MessageRouter) (*Runtime, *RuntimeInfo, error) {
runtimeConfig := config.GetRuntime()
startupLogger.Info("Initialising runtime", zap.String("path", runtimeConfig.Path))
paths, err := GetRuntimePaths(startupLogger, runtimeConfig.Path)
if err != nil {
return nil, nil, err
}
startupLogger.Info("Initialising runtime event queue processor")
eventQueue := NewRuntimeEventQueue(logger, config, metrics)
startupLogger.Info("Runtime event queue processor started", zap.Int("size", config.GetRuntime().EventQueueSize), zap.Int("workers", config.GetRuntime().EventQueueWorkers))
matchProvider := NewMatchProvider()
goModules, goRPCFunctions, goBeforeRtFunctions, goAfterRtFunctions, goBeforeReqFunctions, goAfterReqFunctions, goMatchmakerMatchedFunction, goTournamentEndFunction, goTournamentResetFunction, goLeaderboardResetFunction, allEventFunctions, goMatchNamesListFn, err := NewRuntimeProviderGo(ctx, logger, startupLogger, db, protojsonMarshaler, config, socialClient, leaderboardCache, leaderboardRankCache, leaderboardScheduler, sessionRegistry, sessionCache, matchRegistry, tracker, metrics, streamManager, router, runtimeConfig.Path, paths, eventQueue, matchProvider)
if err != nil {
startupLogger.Error("Error initialising Go runtime provider", zap.Error(err))
return nil, nil, err
}
luaModules, luaRPCFunctions, luaBeforeRtFunctions, luaAfterRtFunctions, luaBeforeReqFunctions, luaAfterReqFunctions, luaMatchmakerMatchedFunction, luaTournamentEndFunction, luaTournamentResetFunction, luaLeaderboardResetFunction, err := NewRuntimeProviderLua(logger, startupLogger, db, protojsonMarshaler, protojsonUnmarshaler, config, socialClient, leaderboardCache, leaderboardRankCache, leaderboardScheduler, sessionRegistry, sessionCache, matchRegistry, tracker, metrics, streamManager, router, allEventFunctions.eventFunction, runtimeConfig.Path, paths, matchProvider)
if err != nil {
startupLogger.Error("Error initialising Lua runtime provider", zap.Error(err))
return nil, nil, err
}
jsModules, jsRPCFunctions, jsBeforeRtFunctions, jsAfterRtFunctions, jsBeforeReqFunctions, jsAfterReqFunctions, jsMatchmakerMatchedFunction, jsTournamentEndFunction, jsTournamentResetFunction, jsLeaderboardResetFunction, err := NewRuntimeProviderJS(logger, startupLogger, db, protojsonMarshaler, protojsonUnmarshaler, config, socialClient, leaderboardCache, leaderboardRankCache, leaderboardScheduler, sessionRegistry, sessionCache, matchRegistry, tracker, metrics, streamManager, router, allEventFunctions.eventFunction, runtimeConfig.Path, runtimeConfig.JsEntrypoint, matchProvider)
if err != nil {
startupLogger.Error("Error initialising JavaScript runtime provider", zap.Error(err))
return nil, nil, err
}
allModules := make([]string, 0, len(jsModules)+len(luaModules)+len(goModules))
for _, module := range jsModules {
allModules = append(allModules, module)
}
for _, module := range luaModules {
allModules = append(allModules, module)
}
for _, module := range goModules {
allModules = append(allModules, module)
}
startupLogger.Info("Found runtime modules", zap.Int("count", len(allModules)), zap.Strings("modules", allModules))
if allEventFunctions.eventFunction != nil {
startupLogger.Info("Registered event function invocation for custom events")
}
if allEventFunctions.sessionStartFunction != nil {
startupLogger.Info("Registered event function invocation", zap.String("id", "session_start"))
}
if allEventFunctions.sessionEndFunction != nil {
startupLogger.Info("Registered event function invocation", zap.String("id", "session_end"))
}
allRPCFunctions := make(map[string]RuntimeRpcFunction, len(goRPCFunctions)+len(luaRPCFunctions)+len(jsRPCFunctions))
jsRpcIDs := make(map[string]bool, len(jsRPCFunctions))
for id, fn := range jsRPCFunctions {
allRPCFunctions[id] = fn
jsRpcIDs[id] = true
startupLogger.Info("Registered JavaScript runtime RPC function invocation", zap.String("id", id))
}
luaRpcIDs := make(map[string]bool, len(luaRPCFunctions))
for id, fn := range luaRPCFunctions {
allRPCFunctions[id] = fn
delete(jsRpcIDs, id)
luaRpcIDs[id] = true
startupLogger.Info("Registered Lua runtime RPC function invocation", zap.String("id", id))
}
goRpcIDs := make(map[string]bool, len(goRPCFunctions))
for id, fn := range goRPCFunctions {
allRPCFunctions[id] = fn
delete(luaRpcIDs, id)
goRpcIDs[id] = true
startupLogger.Info("Registered Go runtime RPC function invocation", zap.String("id", id))
}
allBeforeRtFunctions := make(map[string]RuntimeBeforeRtFunction, len(jsBeforeRtFunctions)+len(luaBeforeRtFunctions)+len(goBeforeRtFunctions))
for id, fn := range jsBeforeRtFunctions {
allBeforeRtFunctions[id] = fn
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", strings.TrimPrefix(strings.TrimPrefix(id, API_PREFIX), RTAPI_PREFIX)))
}
for id, fn := range luaBeforeRtFunctions {
allBeforeRtFunctions[id] = fn
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", strings.TrimPrefix(strings.TrimPrefix(id, API_PREFIX), RTAPI_PREFIX)))
}
for id, fn := range goBeforeRtFunctions {
allBeforeRtFunctions[id] = fn
startupLogger.Info("Registered Go runtime Before function invocation", zap.String("id", strings.TrimPrefix(strings.TrimPrefix(id, API_PREFIX), RTAPI_PREFIX)))
}
allAfterRtFunctions := make(map[string]RuntimeAfterRtFunction, len(jsAfterRtFunctions)+len(luaAfterRtFunctions)+len(goAfterRtFunctions))
for id, fn := range jsAfterRtFunctions {
allAfterRtFunctions[id] = fn
startupLogger.Info("Registered JavaScript runtime After function invocation", zap.String("id", strings.TrimPrefix(strings.TrimPrefix(id, API_PREFIX), RTAPI_PREFIX)))
}
for id, fn := range luaAfterRtFunctions {
allAfterRtFunctions[id] = fn
startupLogger.Info("Registered Lua runtime After function invocation", zap.String("id", strings.TrimPrefix(strings.TrimPrefix(id, API_PREFIX), RTAPI_PREFIX)))
}
for id, fn := range goAfterRtFunctions {
allAfterRtFunctions[id] = fn
startupLogger.Info("Registered Go runtime After function invocation", zap.String("id", strings.TrimPrefix(strings.TrimPrefix(id, API_PREFIX), RTAPI_PREFIX)))
}
allBeforeReqFunctions := jsBeforeReqFunctions
// Register JavaScript Before Req functions
if allBeforeReqFunctions.beforeGetAccountFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "getaccount"))
}
if allBeforeReqFunctions.beforeUpdateAccountFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "updateaccount"))
}
if allBeforeReqFunctions.beforeSessionRefreshFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "sessionrefresh"))
}
if allBeforeReqFunctions.beforeSessionLogoutFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "sessionlogout"))
}
if allBeforeReqFunctions.beforeAuthenticateAppleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticateapple"))
}
if allBeforeReqFunctions.beforeAuthenticateCustomFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticatecustom"))
}
if allBeforeReqFunctions.beforeAuthenticateDeviceFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticatedevice"))
}
if allBeforeReqFunctions.beforeAuthenticateEmailFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticateemail"))
}
if allBeforeReqFunctions.beforeAuthenticateFacebookFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticatefacebook"))
}
if allBeforeReqFunctions.beforeAuthenticateFacebookInstantGameFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticatefacebookinstantgame"))
}
if allBeforeReqFunctions.beforeAuthenticateGameCenterFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticategamecenter"))
}
if allBeforeReqFunctions.beforeAuthenticateGoogleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticategoogle"))
}
if allBeforeReqFunctions.beforeAuthenticateSteamFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "authenticatesteam"))
}
if allBeforeReqFunctions.beforeListChannelMessagesFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listchannelmessages"))
}
if allBeforeReqFunctions.beforeListFriendsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listfriends"))
}
if allBeforeReqFunctions.beforeAddFriendsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "addfriends"))
}
if allBeforeReqFunctions.beforeDeleteFriendsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "deletefriends"))
}
if allBeforeReqFunctions.beforeBlockFriendsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "blockfriends"))
}
if allBeforeReqFunctions.beforeImportFacebookFriendsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "importfacebookfriends"))
}
if allBeforeReqFunctions.beforeImportSteamFriendsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "importsteamfriends"))
}
if allBeforeReqFunctions.beforeCreateGroupFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "creategroup"))
}
if allBeforeReqFunctions.beforeUpdateGroupFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "updategroup"))
}
if allBeforeReqFunctions.beforeDeleteGroupFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "deletegroup"))
}
if allBeforeReqFunctions.beforeJoinGroupFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "joingroup"))
}
if allBeforeReqFunctions.beforeLeaveGroupFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "leavegroup"))
}
if allBeforeReqFunctions.beforeAddGroupUsersFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "addgroupusers"))
}
if allBeforeReqFunctions.beforeBanGroupUsersFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "bangroupusers"))
}
if allBeforeReqFunctions.beforeKickGroupUsersFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "kickgroupusers"))
}
if allBeforeReqFunctions.beforePromoteGroupUsersFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "promotegroupusers"))
}
if allBeforeReqFunctions.beforeDemoteGroupUsersFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "demotegroupusers"))
}
if allBeforeReqFunctions.beforeListGroupUsersFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listgroupusers"))
}
if allBeforeReqFunctions.beforeListUserGroupsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listusergroups"))
}
if allBeforeReqFunctions.beforeListGroupsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listgroups"))
}
if allBeforeReqFunctions.beforeDeleteLeaderboardRecordFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "deleteleaderboardrecord"))
}
if allBeforeReqFunctions.beforeListLeaderboardRecordsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listleaderboardrecords"))
}
if allBeforeReqFunctions.beforeWriteLeaderboardRecordFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "writeleaderboardrecord"))
}
if allBeforeReqFunctions.beforeListLeaderboardRecordsAroundOwnerFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listleaderboardrecordsaroundowner"))
}
if allBeforeReqFunctions.beforeLinkAppleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkapple"))
}
if allBeforeReqFunctions.beforeLinkCustomFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkcustom"))
}
if allBeforeReqFunctions.beforeLinkDeviceFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkdevice"))
}
if allBeforeReqFunctions.beforeLinkEmailFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkemail"))
}
if allBeforeReqFunctions.beforeLinkFacebookFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkfacebook"))
}
if allBeforeReqFunctions.beforeLinkFacebookInstantGameFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkfacebookinstantgame"))
}
if allBeforeReqFunctions.beforeLinkGameCenterFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkgamecenter"))
}
if allBeforeReqFunctions.beforeLinkGoogleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linkgoogle"))
}
if allBeforeReqFunctions.beforeLinkSteamFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "linksteam"))
}
if allBeforeReqFunctions.beforeListMatchesFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listmatches"))
}
if allBeforeReqFunctions.beforeListNotificationsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listnotifications"))
}
if allBeforeReqFunctions.beforeDeleteNotificationFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "deletenotification"))
}
if allBeforeReqFunctions.beforeListStorageObjectsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "liststorageobjects"))
}
if allBeforeReqFunctions.beforeReadStorageObjectsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "readstorageobjects"))
}
if allBeforeReqFunctions.beforeWriteStorageObjectsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "writestorageobjects"))
}
if allBeforeReqFunctions.beforeDeleteStorageObjectsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "deletestorageobjects"))
}
if allBeforeReqFunctions.beforeJoinTournamentFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "jointournament"))
}
if allBeforeReqFunctions.beforeListTournamentRecordsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listtournamentrecords"))
}
if allBeforeReqFunctions.beforeListTournamentsFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listtournaments"))
}
if allBeforeReqFunctions.beforeWriteTournamentRecordFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "writetournamentrecord"))
}
if allBeforeReqFunctions.beforeListTournamentRecordsAroundOwnerFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "listtournamentrecordsaroundowner"))
}
if allBeforeReqFunctions.beforeUnlinkAppleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkapple"))
}
if allBeforeReqFunctions.beforeUnlinkCustomFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkcustom"))
}
if allBeforeReqFunctions.beforeUnlinkDeviceFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkdevice"))
}
if allBeforeReqFunctions.beforeUnlinkEmailFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkemail"))
}
if allBeforeReqFunctions.beforeUnlinkFacebookFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkfacebook"))
}
if allBeforeReqFunctions.beforeUnlinkFacebookInstantGameFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkfacebookinstantgame"))
}
if allBeforeReqFunctions.beforeUnlinkGameCenterFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkgamecenter"))
}
if allBeforeReqFunctions.beforeUnlinkGoogleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinkgoogle"))
}
if allBeforeReqFunctions.beforeUnlinkSteamFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "unlinksteam"))
}
if allBeforeReqFunctions.beforeGetUsersFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "getusers"))
}
if allBeforeReqFunctions.beforeValidatePurchaseAppleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "validatepurchaseapple"))
}
if allBeforeReqFunctions.beforeValidatePurchaseGoogleFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "validatepurchasegoogle"))
}
if allBeforeReqFunctions.beforeValidatePurchaseHuaweiFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before function invocation", zap.String("id", "validatepurchasehuawei"))
}
if allBeforeReqFunctions.beforeEventFunction != nil {
startupLogger.Info("Registered JavaScript runtime Before custom events function invocation")
}
// Register Lua Before Req functions
if luaBeforeReqFunctions.beforeGetAccountFunction != nil {
allBeforeReqFunctions.beforeGetAccountFunction = luaBeforeReqFunctions.beforeGetAccountFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "getaccount"))
}
if luaBeforeReqFunctions.beforeUpdateAccountFunction != nil {
allBeforeReqFunctions.beforeUpdateAccountFunction = luaBeforeReqFunctions.beforeUpdateAccountFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "updateaccount"))
}
if luaBeforeReqFunctions.beforeSessionRefreshFunction != nil {
allBeforeReqFunctions.beforeSessionRefreshFunction = luaBeforeReqFunctions.beforeSessionRefreshFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "sessionrefresh"))
}
if luaBeforeReqFunctions.beforeSessionLogoutFunction != nil {
allBeforeReqFunctions.beforeSessionLogoutFunction = luaBeforeReqFunctions.beforeSessionLogoutFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "sessionlogout"))
}
if luaBeforeReqFunctions.beforeAuthenticateAppleFunction != nil {
allBeforeReqFunctions.beforeAuthenticateAppleFunction = luaBeforeReqFunctions.beforeAuthenticateAppleFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticateapple"))
}
if luaBeforeReqFunctions.beforeAuthenticateCustomFunction != nil {
allBeforeReqFunctions.beforeAuthenticateCustomFunction = luaBeforeReqFunctions.beforeAuthenticateCustomFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticatecustom"))
}
if luaBeforeReqFunctions.beforeAuthenticateDeviceFunction != nil {
allBeforeReqFunctions.beforeAuthenticateDeviceFunction = luaBeforeReqFunctions.beforeAuthenticateDeviceFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticatedevice"))
}
if luaBeforeReqFunctions.beforeAuthenticateEmailFunction != nil {
allBeforeReqFunctions.beforeAuthenticateEmailFunction = luaBeforeReqFunctions.beforeAuthenticateEmailFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticateemail"))
}
if luaBeforeReqFunctions.beforeAuthenticateFacebookFunction != nil {
allBeforeReqFunctions.beforeAuthenticateFacebookFunction = luaBeforeReqFunctions.beforeAuthenticateFacebookFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticatefacebook"))
}
if luaBeforeReqFunctions.beforeAuthenticateFacebookInstantGameFunction != nil {
allBeforeReqFunctions.beforeAuthenticateFacebookInstantGameFunction = luaBeforeReqFunctions.beforeAuthenticateFacebookInstantGameFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticatefacebookinstantgame"))
}
if luaBeforeReqFunctions.beforeAuthenticateGameCenterFunction != nil {
allBeforeReqFunctions.beforeAuthenticateGameCenterFunction = luaBeforeReqFunctions.beforeAuthenticateGameCenterFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticategamecenter"))
}
if luaBeforeReqFunctions.beforeAuthenticateGoogleFunction != nil {
allBeforeReqFunctions.beforeAuthenticateGoogleFunction = luaBeforeReqFunctions.beforeAuthenticateGoogleFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticategoogle"))
}
if luaBeforeReqFunctions.beforeAuthenticateSteamFunction != nil {
allBeforeReqFunctions.beforeAuthenticateSteamFunction = luaBeforeReqFunctions.beforeAuthenticateSteamFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "authenticatesteam"))
}
if luaBeforeReqFunctions.beforeListChannelMessagesFunction != nil {
allBeforeReqFunctions.beforeListChannelMessagesFunction = luaBeforeReqFunctions.beforeListChannelMessagesFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "listchannelmessages"))
}
if luaBeforeReqFunctions.beforeListFriendsFunction != nil {
allBeforeReqFunctions.beforeListFriendsFunction = luaBeforeReqFunctions.beforeListFriendsFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "listfriends"))
}
if luaBeforeReqFunctions.beforeAddFriendsFunction != nil {
allBeforeReqFunctions.beforeAddFriendsFunction = luaBeforeReqFunctions.beforeAddFriendsFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "addfriends"))
}
if luaBeforeReqFunctions.beforeDeleteFriendsFunction != nil {
allBeforeReqFunctions.beforeDeleteFriendsFunction = luaBeforeReqFunctions.beforeDeleteFriendsFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "deletefriends"))
}
if luaBeforeReqFunctions.beforeBlockFriendsFunction != nil {
allBeforeReqFunctions.beforeBlockFriendsFunction = luaBeforeReqFunctions.beforeBlockFriendsFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "blockfriends"))
}
if luaBeforeReqFunctions.beforeImportFacebookFriendsFunction != nil {
allBeforeReqFunctions.beforeImportFacebookFriendsFunction = luaBeforeReqFunctions.beforeImportFacebookFriendsFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "importfacebookfriends"))
}
if luaBeforeReqFunctions.beforeImportSteamFriendsFunction != nil {
allBeforeReqFunctions.beforeImportSteamFriendsFunction = luaBeforeReqFunctions.beforeImportSteamFriendsFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "importsteamfriends"))
}
if luaBeforeReqFunctions.beforeCreateGroupFunction != nil {
allBeforeReqFunctions.beforeCreateGroupFunction = luaBeforeReqFunctions.beforeCreateGroupFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "creategroup"))
}
if luaBeforeReqFunctions.beforeUpdateGroupFunction != nil {
allBeforeReqFunctions.beforeUpdateGroupFunction = luaBeforeReqFunctions.beforeUpdateGroupFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "updategroup"))
}
if luaBeforeReqFunctions.beforeDeleteGroupFunction != nil {
allBeforeReqFunctions.beforeDeleteGroupFunction = luaBeforeReqFunctions.beforeDeleteGroupFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "deletegroup"))
}
if luaBeforeReqFunctions.beforeJoinGroupFunction != nil {
allBeforeReqFunctions.beforeJoinGroupFunction = luaBeforeReqFunctions.beforeJoinGroupFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "joingroup"))
}
if luaBeforeReqFunctions.beforeLeaveGroupFunction != nil {
allBeforeReqFunctions.beforeLeaveGroupFunction = luaBeforeReqFunctions.beforeLeaveGroupFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "leavegroup"))
}
if luaBeforeReqFunctions.beforeAddGroupUsersFunction != nil {
allBeforeReqFunctions.beforeAddGroupUsersFunction = luaBeforeReqFunctions.beforeAddGroupUsersFunction
startupLogger.Info("Registered Lua runtime Before function invocation", zap.String("id", "addgroupusers"))
}
if luaBeforeReqFunctions.beforeBanGroupUsersFunction != nil {
allBeforeReqFunctions.beforeBanGroupUsersFunction = luaBeforeReqFunctions.beforeBanGroupUsersFunction