147 Commits

Author SHA1 Message Date
mordentral
d9ca76cfde Don't need to set this for steam
Don't need to set this for steam, it doesn't really hurt but people keep getting confused by the console warning.
2024-03-08 00:03:12 -05:00
Joshua
c883b1dc75 add auto conversion from my unique net id to the engines new bp accessible one 2024-02-13 10:09:02 -05:00
Joshua
892343a786 final changes 2024-01-22 16:05:26 -05:00
Joshua
3e265f1a64 more changes 2024-01-22 15:36:47 -05:00
Joshua
fe461af3b0 Merge branch 'master' into Refactorwork 2024-01-19 16:06:37 -05:00
Joshua
6ba73a5bbb initial refactor of latent nodes 2024-01-19 16:06:32 -05:00
Joshua (MordenTral) Statzer
f13d9ad8cc Merge pull request #83 from rubyperrin/master
Fix rare memory leak
2024-01-08 14:38:48 -05:00
ruby
2045c91b1d Fix rare memory leak 2024-01-02 15:23:52 +00:00
Joshua
d5e5c73ce6 testing new setup for Advanced steam sessions steam module ref 2023-12-13 10:34:13 -05:00
mordentral
82b1af6e34 ASS needed a new overlay type to be able to open 2023-11-12 13:58:38 -05:00
Joshua
8ce4613d71 go back to pre default loading phase 2023-11-01 08:52:18 -04:00
mordentral
0b79fb1817 no real reason 2023-10-16 21:30:49 -04:00
Joshua
069b2cbf87 Merge branch 'master' of https://github.com/mordentral/AdvancedSessionsPlugin 2023-10-12 11:09:42 -04:00
Joshua
9713ca512c not sure why these were both in private and public dependencies, looks like a copy paste typo. 2023-10-12 11:06:47 -04:00
mordentral
be280a6dfd Removed the steam subsystem entirely from the advanced steam module
Removed the steam subsystem entirely from the advanced steam module. In 5.3 it has a lot of issues with it for some reason, the steam subsystem is not loading if I directly reference it.

Changes should also work in prior versions.
2023-10-10 20:25:51 -04:00
Joshua (MordenTral) Statzer
b5c8b348c0 Merge pull request #77 from Nadwey/master
Fix build on platforms other than Windows, Mac or Linux
2023-08-22 09:00:21 -04:00
Nadwey
c292d70374 Fix build on platforms other than Windows, Mac or Linux 2023-08-21 21:32:48 +02:00
mordentral
df22d77b10 Adding in Steam Notifications Subsystem
Adding in Steam Notifications Subsystem, For now it just adds the OnOverlayActivated event, but it is expandable into the future being a subsystem.
2023-07-26 16:59:53 -04:00
Joshua
fc998399a2 Merge branch 'master' of https://github.com/mordentral/AdvancedSessionsPlugin 2023-07-26 08:53:04 -04:00
Joshua
8d92717bf6 update session add advertisement 2023-07-26 08:53:01 -04:00
Joshua (MordenTral) Statzer
e6c63eb756 Merge pull request #74 from Scylin232/master
Fix compilation error due to missing 'Online.h' inclusion
2023-06-26 08:22:42 -04:00
Scylin232
8ca00321fe Fix compilation error due to missing 'Online.h' inclusion 2023-06-24 08:15:31 +02:00
Joshua
b18041438e online session online session names additionnames addition 2023-05-11 15:13:15 -04:00
Joshua
2a2ca9a0d2 Mac filter text now only has the 5 parameter version. 2023-04-24 15:38:54 -04:00
Joshua
3d41678a62 forgot to delete definition 2023-01-25 15:01:24 -05:00
Joshua
5d2d63df75 fix multiple session results when searching both dedicated and lobbies
fix multiple session results when searching both dedicated and lobbies, its not a problem on steam but with lan and such it returns the same results as it doesn't care about presence.
2023-01-25 14:59:26 -05:00
Joshua
843a6024a5 Merge branch '5.1-Preview' 2022-11-15 12:07:58 -05:00
mordentral
6469e5e0bf they use a new virtual type hash now 2022-10-11 19:38:48 -04:00
Joshua
6c26d78568 a fix 2022-10-07 12:39:21 -04:00
Joshua
b6804f0f56 initial compiling version 2022-10-06 15:30:31 -04:00
Joshua (MordenTral) Statzer
382ed08217 Merge pull request #48 from Elewyth/master
properly forward UWorld::ServerTravel return value
2022-09-08 14:06:02 -04:00
Marc Etter
f760855494 properly forward UWorld::ServerTravel return value 2022-09-08 19:01:27 +02:00
Joshua
fe76b60b2e ue5 correction 2022-08-30 15:32:43 -04:00
Joshua
7f1b47f42d set cached unique net id in auto login as well 2022-08-30 08:42:41 -04:00
Joshua
3ac5d6c664 ported changes over 2022-08-22 16:00:22 -04:00
Joshua
fd33fc34a5 correct the create session node not passing on bAllowJoingViaPresence 2022-06-24 08:10:11 -04:00
Joshua
bc26be2a12 porting session change to ue5 2022-05-03 08:39:29 -04:00
Joshua
936532f1a0 forcing steam shared on
forcing steam shared on, its off by default and including steam subsystem isn't automatically turning it on.
2022-04-26 09:01:05 -04:00
Joshua
64710df075 whoops 2022-04-08 12:04:03 -04:00
Joshua
ab9de1b344 re-enabling end session 2022-04-08 10:54:04 -04:00
Joshua
bf4d99cba8 adding in pull request manually
https://github.com/mordentral/AdvancedSessionsPlugin/pull/32 manually merging due to changes since creation
2022-04-08 10:53:41 -04:00
Joshua
f7f56e7038 Merge branch 'UE5-ReleaseStaging' 2022-04-05 15:29:19 -04:00
Joshua
90fff579ba manually merging server travel node to ue5 2022-03-11 13:45:01 -05:00
Joshua (MordenTral) Statzer
2520d15e54 Merge pull request #30 from uno1982/master
Add server travel blueprint node.
2022-03-11 13:40:23 -05:00
uno1982
fbbb39c06c Merge pull request #1 from uno1982/uno1982-Servertravel
servertravel changes
2022-03-11 11:04:48 -06:00
uno1982
4922cd2154 Update AdvancedSessionsLibrary.h
Fixed typo on bShouldSkipGameNotify
2022-03-10 20:48:21 -06:00
uno1982
36cb58ea15 Added ServerTravel to library cpp 2022-03-10 20:34:11 -06:00
uno1982
e9747ff440 Update AdvancedSessionsLibrary.h 2022-03-10 20:10:48 -06:00
Joshua
e1ed0f22b6 normalizing EOL 2022-03-07 11:03:10 -05:00
Joshua
0de641f7d9 adding gitattributes 2022-03-07 10:46:44 -05:00
Joshua
295ab98a91 correct this pull request for ue5 2022-03-07 09:22:25 -05:00
Joshua (MordenTral) Statzer
18475eb2ef Merge pull request #24 from lotodore/login_update_playerstate_uniqueid
Update PlayerState UniqueId after Login

Good pull request, accepted
2022-03-07 08:23:56 -05:00
Joshua (MordenTral) Statzer
9784cd2f01 Merge pull request #25 from lotodore/change_type_to_authtype
Rename Login parameter "Type" to "AuthType".

Not a relevant change, it predates EOS, but will merge for clarity
2022-03-07 08:23:56 -05:00
Joshua (MordenTral) Statzer
ee9252a0df Merge pull request #24 from lotodore/login_update_playerstate_uniqueid
Update PlayerState UniqueId after Login

Good pull request, accepted
2022-03-07 08:22:33 -05:00
Joshua (MordenTral) Statzer
b3cc471bf3 Merge pull request #25 from lotodore/change_type_to_authtype
Rename Login parameter "Type" to "AuthType".

Not a relevant change, it predates EOS, but will merge for clarity
2022-03-07 08:20:21 -05:00
Lothar May
9bb2c553cd Rename parameter "Type" to "AuthType". 2022-03-05 14:32:41 +01:00
Lothar May
56639eb4a7 Fixing build of plugin changes on MacOS.
(cherry picked from commit cc311df9699a99305fe3c7d5d83f4fb0bb4b5550)
2022-03-05 13:47:55 +01:00
Lothar May
31c4be3629 Update UniqueId in login callback. See also ShowLoginUICallbackProxy.cpp in UE sources.
(cherry picked from commit 826bef7b861e8c20013033b57dd45cd8fec304e5)
2022-03-05 13:47:47 +01:00
mordentral
2e43a65acd fix include 2022-02-28 17:08:09 -05:00
Joshua
09bbe211a8 fix type and some functions that are soon to be replaced 2022-02-25 15:06:42 -05:00
Joshua
fded4d065b commit to bring to parity 2022-02-07 10:29:19 -05:00
Joshua
b0ae86b017 revert to ue5 EA on this branch, spool up a new one 2022-02-07 10:28:08 -05:00
Joshua
4d913be381 Merge branch 'master' into UE5-Prerelease 2022-01-27 09:15:56 -05:00
Joshua (MordenTral) Statzer
b986d7be2d Merge pull request #19 from mrcodesx/issue-18
Fix: Issue #18 Update session fails with "NO REGISTERED SESSIONS" error
2022-01-21 13:41:54 -05:00
MrCodesX
82b2f9f594 Fix: Issue #18 Update session not finding sessions to update 2022-01-09 00:54:42 -06:00
Joshua (MordenTral) Statzer
ec634238f8 Merge pull request #16 from Ji-Rath/EOS_QOL
EOS QOL
2021-12-21 14:37:19 -05:00
Ji-Rath
21b5b139d9 Add UseLobbiesVoiceChat option for CreateSession
Allows the user to setup voice chat lobbies if the API supports it
2021-12-17 15:47:39 -06:00
Ji-Rath
7b8bebac66 Add AutoLoginUserCallbackProxy
Implement AutoLogin function, can be used to login automatically using the EOS SDK Dev Auth Tool
2021-12-17 15:45:18 -06:00
Ji-Rath
444b632a72 Add type parameter to LoginUser
Add type parameter so EOS can use "accountportal" to authenticate, falls back to default implementation if left blank
2021-12-17 15:27:22 -06:00
Joshua
8192f73ca7 fix bad header 2021-10-25 08:26:13 -04:00
Joshua
f2a33fe1c6 Revert "update for new session option"
This reverts commit b72b0d59fe.
2021-10-22 15:50:52 -04:00
Joshua
c59f4bba43 Revert "fix default value for lobby sessions on create session"
This reverts commit 7b21ee2344.
2021-10-22 15:50:45 -04:00
Joshua
7b21ee2344 fix default value for lobby sessions on create session
fix default value for lobby sessions on create session
2021-10-22 15:32:24 -04:00
Joshua
94fb993ad7 fix default value for lobby sessions on create session
fix default value for lobby sessions on create session
2021-10-22 15:31:22 -04:00
Joshua
b72b0d59fe update for new session option
update for new session option
2021-10-22 15:31:06 -04:00
Louis Raverdy
5b2260079c Update SteamRequestGroupOfficersCallbackProxy.h 2021-10-18 22:02:12 +02:00
Louis Raverdy
c4df122248 Update AdvancedSteamFriendsLibrary.h 2021-10-18 22:01:46 +02:00
Louis Raverdy
6065bd9a36 Update SteamRequestGroupOfficersCallbackProxy.cpp 2021-10-18 22:00:37 +02:00
Joshua
d67c039088 support steam bug on mac
support steam bug on mac
2021-10-12 10:01:02 -04:00
Joshua
6c392ee1fb backing out search lobbies in ue5, it doesn't exist here yet
backing out search lobbies in ue5, it doesn't exist here yet
2021-09-29 08:39:45 -04:00
Joshua
4b7cffc1c0 add lobby search to find
add lobby search to find
2021-09-13 08:21:23 -04:00
Joshua
0be6427845 corrected uplugin versions
corrected uplugin versions
2021-09-01 13:24:33 -04:00
Joshua
816b701963 add lobby search to find
add lobby search to find
2021-08-24 09:22:34 -04:00
Joshua
e9bea6cac0 fix default value for lobby sessions on create session
fix default value for lobby sessions on create session
2021-08-23 08:39:21 -04:00
Joshua
a63bb0916a Merge branch '4.27-Port' 2021-08-19 13:20:53 -04:00
Joshua
be6f532c1e Added new steam sessions functions
IsOverlay Enabled
InitTextFiltering
FilterText
IsSteamInBigPictureMode
2021-08-16 12:52:55 -04:00
Joshua
1f6b7dbb3b Added new steam sessions functions
IsOverlay Enabled
InitTextFiltering
FilterText
IsSteamInBigPictureMode
2021-08-16 12:52:44 -04:00
Joshua
c391737812 fix ADmissing properties
fix ADmissing properties
2021-08-09 15:35:20 -04:00
Joshua
156025af2d update for new session option
update for new session option
2021-06-10 09:50:13 -04:00
Joshua
ce25430643 packages
packages
2021-06-07 12:27:07 -04:00
Joshua
dfb5ad544a removed win32 check
removed win32 check
2021-05-28 10:03:52 -04:00
Joshua
188d5059fc forgot to update AS version
forgot to update AS version
2021-01-08 08:22:45 -05:00
Joshua
e561b92679 added comparison operator for FBPUniqueNetID
added comparison operator for FBPUniqueNetID, so that STD functions will work with it.
2020-11-13 15:42:24 -05:00
Joshua
0cee743c63 adding plater state header fix
adding plater state header fix
2020-09-18 09:22:34 -04:00
mordentral
bfd459b461 Ban/Kick Player
Adds BP nodes to the library to kick / ban player

Since built in game sessions does not actually implement ban player, I also provide a very basic naive implementation with a custom game session that bans for the duration of the session. A real implementation would save out the net id and also perform the check in the game mode before spooling up a player for login.
2020-06-27 18:43:06 -04:00
mordentral
17228f6bbb added gitignore
added gitignore
2020-06-07 20:50:51 -04:00
mordentral
c32fc3488f Update README.md 2020-06-05 21:59:07 -04:00
mordentral
05497d3226 Taking 4.25 live
Former-commit-id: 8d82ec41ffb783c0cfbb667ca1aa5061afa74c8e
2020-05-05 19:09:42 -04:00
mordentral
2216aaf041 made a note on the literal search bool nodes that they aren't used for filtering
on steam


Former-commit-id: dd4423b2810500c7106c065ca632a5bd4794749a
2020-02-04 09:51:33 -05:00
mordentral
192307b542 fixing a replace operation that screwed up the .uplugin files
Former-commit-id: bef14f3afc4f9cff36b62441ccf79ed8e6d21edc
2019-12-09 10:47:53 -05:00
mordentral
51cf0acb2e Taking 4.24 live
Former-commit-id: 9fd092e594a1c561c109633f8661a766e5a2a6e4
2019-12-09 10:26:49 -05:00
mordentral
3c4ba2af3b fixed deprecating function call
Former-commit-id: 3b0a2802808bce6cf442f233e5f041d8b0ea3505
2019-10-29 10:12:27 -04:00
mordentral
8744035160 Added world context to a bunch of relevant nodes.
Should likely add it to others in the future as well.


Former-commit-id: c41024927d6525c3c35ff609bdffdb2960b6e3ae
2019-10-29 09:52:28 -04:00
mordentral
71f16cadd2 fixed a compilation issue
Former-commit-id: 2a9d3410b912fa418c62e54561dfe0a60df50c33
2019-10-15 14:20:02 -04:00
mordentral
fdfc2d272f added an include to fix up potential Gengine issues
Former-commit-id: d3b5af9617865f37f3c207ec41e42d1ea107d0c3
2019-10-15 10:07:13 -04:00
mordentral
297848aed8 merging 4.23
Former-commit-id: 15eff386a29a783738c08a95ccced0bf750e7611
2019-09-04 16:22:01 -04:00
morden
60d1d272a5 Added more exclusions that were missing so that this module works with android
Former-commit-id: 761446368dbf589018c1a9cb9ab94bf44544569d
2019-08-04 15:43:13 -04:00
morden
c3f889c9c5 cleaned up some includes
Former-commit-id: f5553794bc0bb12c833829ef2728df168994c694
2019-05-25 13:15:54 -04:00
mordentral
2e93c6095a Converted over to using the newer session names
Former-commit-id: f6d820a363d9e6881c647d9d29059ade0ac05746
2019-04-18 15:11:12 -04:00
mordentral
6007506189 Added another session id utility function
Former-commit-id: 4e97162f7c10db3bd97b3756fa2de911e360b662
2019-04-18 13:35:15 -04:00
mordentral
0952d9b18a Added a new utility function to the Advanced Sessions Function Library
(Thanks to Vorixo)

Gets the specified session results session ID as a string


Former-commit-id: da5f0345f3e48ac0c832dbdbc365b0111341dd0b
2019-04-17 15:32:12 -04:00
morden
438d0a69ba Fixed a steam id error
Former-commit-id: cb35546a02707558f615fc2d20a3e2af5fe6d3c8
2019-04-05 19:51:00 -04:00
J
85e9b54fab Merged 4.22 into default
Former-commit-id: 70a1989c1dc8a6925fffd5588906629c63b8ffa7
2019-04-02 18:19:51 +00:00
mordentral
ba28fccfe0 pushing 4.22 live
Former-commit-id: e68353ec156bef65a4823eae2b056e5f5b0878aa
2019-03-26 12:52:48 -04:00
mordentral
d71aaede8d Added OpenSteamUserOverlay to the AdvancedSteamFriendsLibrary
Former-commit-id: d65ec87132032ccfbc06dac90630548ee56d800f
2019-01-15 12:56:03 -05:00
mordentral
38b5c96cbd Adding extended comment to create advanced session, thanks rumbleball
Former-commit-id: 1ed8d2f155d8ea51df6649b674636ceb87c27661
2018-12-05 09:49:57 -05:00
mordentral
ad745512ac Switched to epics new hashing setup for unique ids
Also added new function GetLocalSteamIDFromSteam.


Former-commit-id: 7a15f500cd86064444cedb47433417b7bb9298e4
2018-11-14 14:08:45 -05:00
mordentral
ce7d8b1bf3 4.21 update
Former-commit-id: 91ebbaafc5a4f262d0b811c22b2a83799219fb15
2018-11-07 14:13:15 -05:00
mordentral
abb9e5687c fixed some case sensitivity issues with player controller include.
Former-commit-id: 433cd31b27d21c232453b038a1bd3c077bfb43d3
2018-10-23 14:30:29 -04:00
mordentral
47c6981a2a Fixing the blueprint events being thrown in the steam callback thread.
Former-commit-id: e333ce44217f61acd3545ea12a33a5fddcd27d98
2018-09-28 14:37:34 -04:00
mordentral
20f99a5e10 Removing a test I had been doing like a year ago from GetFriendGamePlayed function
Former-commit-id: 7e0d599ed253f90b789850578accda5d89c1f0d6
2018-08-17 14:33:19 -04:00
morden
289fa84dd5 Large header file cleanup, removing engine minimal
Former-commit-id: 44000ab1d974311615c30ba2fe1f7cd9d6c61ca2
2018-07-30 20:37:20 -04:00
morden
b8a5e7500b some more include path changes for 4.20's weirdness
Former-commit-id: b5adb4101cdf41d29ba0c1d9ecbfb306b727fc26
2018-07-29 18:59:52 -04:00
mordentral
4cc84d68c4 Fixed some more includes
Former-commit-id: 4d8a7bfa7bf7dfbecfa85bdebb0f4baf28ae6a1d
2018-07-23 08:18:44 -04:00
mordentral
b553a8c3b6 Replaced some more interface includes
Former-commit-id: da6919b9a3dc9ee0e75d232e2a47caffd84e2d81
2018-07-20 10:39:08 -04:00
J
bc0e8f7d1b Merged 4.20 Beta into default
Former-commit-id: 5d177fa3f45a0f4430150d0b321dc9eecba23815
2018-07-18 13:23:58 -04:00
mordentral
886b4c2f8a Final sessions commit
Former-commit-id: 1151cf522d737add4908b62dd2616e3260bc7049
2018-07-18 13:23:12 -04:00
mordentral
47775e70bf 4.20 update, working
Former-commit-id: b4d3b7358c168e4e34576b001d18c0cc3b5d8c59
2018-06-21 14:06:02 -04:00
J
924b1ecf1c README.md edited online with Bitbucket
Former-commit-id: 04d85045133970c8e3e956281a58cdec437b332d
2018-04-04 14:47:41 +00:00
J
c73b96993c Merged 4.19 Beta into default
Former-commit-id: 56f3400a30ceb21ce5cce9dc73511e64fb2e514e
2018-04-04 10:41:49 -04:00
J
0229b69d9c Close branch 4.19 Beta
Former-commit-id: 1c0ff2831cd4ddf6e4f511d0399926aa88b6d74b
2018-04-04 10:41:49 -04:00
mordentral
ad2881cd75 Updated some documentation comments
Prepping for auto documentation generation


Former-commit-id: a26d6bbb5c6ba5e11d096bfaa486fd08c5b149ff
2018-04-04 10:40:26 -04:00
mordentral
d007eed9a8 Update module files
Former-commit-id: f88e13eeeb0741e9809aceeb902347d6eea760da
2018-02-27 08:53:00 -05:00
morden
37891f168a Backed out changeset: cdeecf8d12f5
Former-commit-id: a312d44bca502ca3252ced596c326e26c3a89d35
2018-02-08 17:37:39 -05:00
morden
c2a5598582 Backed out changeset: e30e5f51636b
Former-commit-id: eb6dcaf4988028da6feb01f69e465fdfbe497e74
2018-02-08 17:37:28 -05:00
morden
90e7a3f7e4 Changed the findsessions to force searching presence off for dedicated server
searching.

I am fairly sure it defaults to false, but just in case.


Former-commit-id: ef5c861daa1e7259d81cef046ada39d82f403ac1
2018-02-08 17:29:55 -05:00
morden
2db3b7221c Changed the findsessions to force searching presence off for dedicated server
searching.

I am fairly sure it defaults to false, but just in case.


Former-commit-id: 725cd3a3e9b3914bed549ff18a93334348075493
2018-02-08 17:29:55 -05:00
morden
ea77c18a2e 4.19
Former-commit-id: 58eebfc1e9bfa9211a5acde5a65e75254c5904ea
2018-01-16 21:32:40 -05:00
mordentral
483ffd5f6b Thanks to CriErr for the following submission via a pull request.
Made some small modifications to them but they are mostly the same.


Former-commit-id: f304534c4f34dd92a3e6d96a87e3f2652321b1ae
2017-11-22 09:50:03 -05:00
mordentral
64218a7f5b Fixing a missing IsValid check in FindSessions
Former-commit-id: c4e3fc15f93f71fe8256be447da02af75cfc72c2
2017-10-31 10:03:43 -04:00
morden
651292d8a9 Header file cleanup
Former-commit-id: e2a964c8464034860505b51d5ef4ece9bf1ad8e6
2017-08-31 23:56:34 -04:00
morden
f338fd62f2 Removed an unessacary player controller check in CreateSession
Added a valid player controller check and instant fail if not true.


Former-commit-id: b21de68a2c16fde8eae56c6d92da30d5fb8955d7
2017-08-19 18:57:55 -04:00
mordentral
fcba71790f Adding dependancy modules
Former-commit-id: 86081d7970d5ce82bdd582aae222c22331ebe507
2017-08-08 15:48:44 -04:00
J
ab557a31d5 Merged 4.17 beta into default
Former-commit-id: 710fe29881f2cba9f4957b64573ed003cd233836
2017-08-07 12:51:34 -04:00
J
2faf24bce3 Close branch 4.17 beta
Former-commit-id: a03b09bcdb05545872adb9319e372c745b063540
2017-08-07 12:51:34 -04:00
mordentral
9b2899cf28 Updating some functions for 4.17
Former-commit-id: 77d4a2b8d5f2e3949d676b1968ee405e25989c7d
2017-08-03 16:09:14 -04:00
mordentral
f5f801273d 4.17 changes
Former-commit-id: 401105bdd16dfc01e118f7d96daf63cf8360503a
2017-07-24 08:30:57 -04:00
68 changed files with 6046 additions and 4410 deletions

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
* text=auto
*.bat eol=crlf

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
.hg/
binaries/
deriveddatacache/
.vs/
build/
intermediate/
PACKPLUGIN/
saved/
*.orig

View File

@@ -1,20 +1,34 @@
{ {
"FileVersion" : 3, "FileVersion": 3,
"FriendlyName": "Advanced Sessions",
"FriendlyName" : "Advanced Sessions", "Version": 5.1,
"Version" : 1.9, "VersionName": "5.1",
"VersionName": "1.9", "Description": "Adds new blueprint functions to handle more advanced session operations.",
"Description" : "Adds new blueprint functions to handle more advanced session operations.", "Category": "Advanced Sessions Plugin",
"Category" : "Advanced Sessions Plugin", "CreatedBy": "Joshua Statzer",
"CreatedBy" : "Joshua Statzer", "CreatedByURL": "N/A",
"CreatedByURL" : "N/A", "Modules": [
{
"Modules" : "Name": "AdvancedSessions",
[ "Type": "Runtime",
{ "LoadingPhase": "PreDefault"
"Name" : "AdvancedSessions", }
"Type" : "RunTime", ],
"LoadingPhase" : "PreDefault" "Plugins": [
} {
] "Name": "OnlineSubsystem",
"Enabled": true
},
{
"Name": "OnlineSubsystemUtils",
"Enabled": true
}
],
"DocsURL": "",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": false,
"IsBetaVersion": false,
"IsExperimentalVersion": false,
"Installed": false
} }

View File

@@ -0,0 +1,8 @@
[FilterPlugin]
; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and
; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively.
;
; Examples:
; /README.txt
; /Extras/...
; /Binaries/ThirdParty/*.dll

View File

@@ -1,18 +1,17 @@
using UnrealBuildTool; using UnrealBuildTool;
using System.IO; using System.IO;
public class AdvancedSessions : ModuleRules public class AdvancedSessions : ModuleRules
{ {
public AdvancedSessions(ReadOnlyTargetRules Target) : base(Target) public AdvancedSessions(ReadOnlyTargetRules Target) : base(Target)
{ {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
//bEnforceIWYU = true; //bEnforceIWYU = true;
Definitions.Add("WITH_ADVANCED_SESSIONS=1"); PublicDefinitions.Add("WITH_ADVANCED_SESSIONS=1");
PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ }); // PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ });
PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" }); // PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" });
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets"/*"Voice", "OnlineSubsystemSteam"*/ }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets"/*"Voice", "OnlineSubsystemSteam"*/ });
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/}); }
}
} }

View File

@@ -1,63 +1,63 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
//#include "OnlineFriendsInterface.h" //#include "OnlineFriendsInterface.h"
//#include "OnlineUserInterface.h" //#include "OnlineUserInterface.h"
//#include "OnlineMessageInterface.h" //#include "OnlineMessageInterface.h"
//#include "OnlinePresenceInterface.h" //#include "OnlinePresenceInterface.h"
//#include "Engine/GameInstance.h" //#include "Engine/GameInstance.h"
#include "OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
//#include "UObjectIterator.h" //#include "UObjectIterator.h"
#include "AdvancedExternalUILibrary.generated.h" #include "AdvancedExternalUILibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedExternalUILog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedExternalUILog, Log, All);
UCLASS() UCLASS()
class UAdvancedExternalUILibrary : public UBlueprintFunctionLibrary class UAdvancedExternalUILibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* External UI Functions *************// //********* External UI Functions *************//
// Show the UI that handles the Friends list // Show the UI that handles the Friends list
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void ShowFriendsUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result); static void ShowFriendsUI(UObject* WorldContextObject, APlayerController *PlayerController, EBlueprintResultSwitch &Result);
// Show the UI that handles inviting people to your game // Show the UI that handles inviting people to your game
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void ShowInviteUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result); static void ShowInviteUI(UObject* WorldContextObject, APlayerController *PlayerController, EBlueprintResultSwitch &Result);
// Show the UI that shows the leaderboard (doesn't work with steam) // Show the UI that shows the leaderboard (doesn't work with steam)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void ShowLeaderBoardUI(FString LeaderboardName, EBlueprintResultSwitch &Result); static void ShowLeaderBoardUI(UObject* WorldContextObject, FString LeaderboardName, EBlueprintResultSwitch &Result);
// Show the UI that shows a web URL // Show the UI that shows a web URL
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", AutoCreateRefTerm = "AllowedDomains")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", AutoCreateRefTerm = "AllowedDomains", WorldContext = "WorldContextObject"))
static void ShowWebURLUI(FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded = false , bool bShowBackground = false, bool bShowCloseButton = false, int32 OffsetX = 0, int32 OffsetY = 0, int32 SizeX = 0, int32 SizeY = 0); static void ShowWebURLUI(UObject* WorldContextObject, FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded = false , bool bShowBackground = false, bool bShowCloseButton = false, int32 OffsetX = 0, int32 OffsetY = 0, int32 SizeX = 0, int32 SizeY = 0);
// Show the UI that shows a web URL // Show the UI that shows a web URL
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (WorldContext = "WorldContextObject"))
static void CloseWebURLUI(); static void CloseWebURLUI(UObject* WorldContextObject);
// Show the UI that shows the profile of a uniquenetid // Show the UI that shows the profile of a uniquenetid
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result); static void ShowProfileUI(UObject* WorldContextObject, const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result);
// Show the UI that shows the account upgrade UI (doesn't work with steam) // Show the UI that shows the account upgrade UI (doesn't work with steam)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedExternalUI", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result); static void ShowAccountUpgradeUI(UObject* WorldContextObject, const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result);
}; };

View File

@@ -1,143 +1,145 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "Engine/Engine.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "BlueprintDataDefinitions.h"
#include "Online.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "OnlineSubsystem.h" #include "Online.h"
#include "OnlineFriendsInterface.h" #include "OnlineSubsystem.h"
#include "OnlineUserInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "OnlineMessageInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "OnlinePresenceInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "Engine/GameInstance.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/LocalPlayer.h" #include "Engine/GameInstance.h"
#include "OnlineSessionInterface.h" #include "Engine/LocalPlayer.h"
#include "OnlineSessionSettings.h" #include "Interfaces/OnlineSessionInterface.h"
#include "UObjectIterator.h" #include "OnlineSessionSettings.h"
#include "AdvancedFriendsInterface.h" #include "UObject/UObjectIterator.h"
#include "AdvancedFriendsInterface.h"
#include "AdvancedFriendsGameInstance.generated.h"
#include "AdvancedFriendsGameInstance.generated.h"
//General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsInterfaceLog, Log, All); //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsInterfaceLog, Log, All);
UCLASS()
class ADVANCEDSESSIONS_API UAdvancedFriendsGameInstance : public UGameInstance UCLASS()
{ class ADVANCEDSESSIONS_API UAdvancedFriendsGameInstance : public UGameInstance
GENERATED_BODY() {
public: GENERATED_BODY()
public:
UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer);
UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallFriendInterfaceEventsOnPlayerControllers; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallFriendInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallIdentityInterfaceEventsOnPlayerControllers; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallIdentityInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallVoiceInterfaceEventsOnPlayerControllers; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedFriendsInterface)
bool bCallVoiceInterfaceEventsOnPlayerControllers;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface)
bool bEnableTalkingStatusDelegate; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = AdvancedVoiceInterface)
bool bEnableTalkingStatusDelegate;
//virtual void PostLoad() override;
virtual void Shutdown() override; //virtual void PostLoad() override;
virtual void Init() override; virtual void Shutdown() override;
virtual void Init() override;
//*** Session invite received by local ***//
FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate; //*** Session invite received by local ***//
FDelegateHandle SessionInviteReceivedDelegateHandle; FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
FDelegateHandle SessionInviteReceivedDelegateHandle;
//const FUniqueNetId& /*UserId*/, const FUniqueNetId& /*FromId*/, const FString& /*AppId*/, const FOnlineSessionSearchResult& /*InviteResult*/
void OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString & AppId, const FOnlineSessionSearchResult& SessionToJoin); //const FUniqueNetId& /*UserId*/, const FUniqueNetId& /*FromId*/, const FString& /*AppId*/, const FOnlineSessionSearchResult& /*InviteResult*/
void OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString & AppId, const FOnlineSessionSearchResult& SessionToJoin);
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") // After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
void OnSessionInviteReceived(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FString& AppId, const FBlueprintSessionResult& SessionToJoin); UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnSessionInviteReceived(int32 LocalPlayerNum, FBPUniqueNetId PersonInviting, const FString& AppId, const FBlueprintSessionResult& SessionToJoin);
//*** Session invite accepted by local ***//
FOnSessionUserInviteAcceptedDelegate SessionInviteAcceptedDelegate; //*** Session invite accepted by local ***//
FDelegateHandle SessionInviteAcceptedDelegateHandle; FOnSessionUserInviteAcceptedDelegate SessionInviteAcceptedDelegate;
FDelegateHandle SessionInviteAcceptedDelegateHandle;
void OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin);
void OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin);
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends") // After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
void OnSessionInviteAccepted(int32 LocalPlayerNum, FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SessionToJoin); // This function is currently not hooked up in any of Epics default subsystems, it is here for custom subsystems
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnSessionInviteAccepted(int32 LocalPlayerNum, FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SessionToJoin);
// After a voice status has changed this event is triggered if the bEnableTalkingStatusDelegate property is true
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedVoice")
void OnPlayerTalkingStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking); // After a voice status has changed this event is triggered if the bEnableTalkingStatusDelegate property is true
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedVoice")
void OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking); void OnPlayerTalkingStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking);
FOnPlayerTalkingStateChangedDelegate PlayerTalkingStateChangedDelegate; void OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking);
FDelegateHandle PlayerTalkingStateChangedDelegateHandle;
FOnPlayerTalkingStateChangedDelegate PlayerTalkingStateChangedDelegate;
FDelegateHandle PlayerTalkingStateChangedDelegateHandle;
// Called when the designated LocalUser has changed login state
UFUNCTION(BlueprintImplementableEvent , Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginChanged"))
void OnPlayerLoginChanged(int32 PlayerNum); // Called when the designated LocalUser has changed login state
UFUNCTION(BlueprintImplementableEvent , Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginChanged"))
void OnPlayerLoginChangedMaster(int32 PlayerNum); void OnPlayerLoginChanged(int32 PlayerNum);
FOnLoginChangedDelegate PlayerLoginChangedDelegate;
FDelegateHandle PlayerLoginChangedDelegateHandle; void OnPlayerLoginChangedMaster(int32 PlayerNum);
FOnLoginChangedDelegate PlayerLoginChangedDelegate;
// Called when the designated LocalUser has changed login status FDelegateHandle PlayerLoginChangedDelegateHandle;
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginStatusChanged"))
void OnPlayerLoginStatusChanged(int32 PlayerNum, EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId NewPlayerUniqueNetID); // Called when the designated LocalUser has changed login status
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedIdentity", meta = (DisplayName = "OnPlayerLoginStatusChanged"))
void OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID); void OnPlayerLoginStatusChanged(int32 PlayerNum, EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId NewPlayerUniqueNetID);
FOnLoginStatusChangedDelegate PlayerLoginStatusChangedDelegate;
FDelegateHandle PlayerLoginStatusChangedDelegateHandle; void OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID);
FOnLoginStatusChangedDelegate PlayerLoginStatusChangedDelegate;
FDelegateHandle PlayerLoginStatusChangedDelegateHandle;
//*** Session Invite Received From Friend ***//
// REMOVED BECAUSE IT NEVER GETS CALLED
/*FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate; //*** Session Invite Received From Friend ***//
FDelegateHandle SessionInviteReceivedDelegateHandle; // REMOVED BECAUSE IT NEVER GETS CALLED
/*FOnSessionInviteReceivedDelegate SessionInviteReceivedDelegate;
void OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session); FDelegateHandle SessionInviteReceivedDelegateHandle;
// After a session invite has been sent from a friend this event is triggered, call JoinSession on the session result to join it void OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session);
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnSessionInviteReceived(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session); // After a session invite has been sent from a friend this event is triggered, call JoinSession on the session result to join it
*/ UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnSessionInviteReceived(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session);
//*** Friend Invite Accepted ***// */
/*FOnInviteAcceptedDelegate FriendInviteAcceptedDelegate;
FDelegateHandle FriendInviteAcceptedDelegateHandle; //*** Friend Invite Accepted ***//
/*FOnInviteAcceptedDelegate FriendInviteAcceptedDelegate;
void OnFriendInviteAcceptedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerInvited); FDelegateHandle FriendInviteAcceptedDelegateHandle;
// After a session invite has been accepted by a friend this event is triggered void OnFriendInviteAcceptedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerInvited);
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnFriendInviteAccepted(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerInvited); // After a session invite has been accepted by a friend this event is triggered
*/ UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnFriendInviteAccepted(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerInvited);
//*** Friend Invite Rejected ***// */
/*FOnInviteRejectedDelegate SessionInviteRejectedByFriendDelegate;
FDelegateHandle InviteRejectedByFriendDelegateHandle; //*** Friend Invite Rejected ***//
/*FOnInviteRejectedDelegate SessionInviteRejectedByFriendDelegate;
void OnFriendInviteRejectedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerDeclined); FDelegateHandle InviteRejectedByFriendDelegateHandle;
// After a friend invite has been rejected this event is triggered void OnFriendInviteRejectedDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &PlayerDeclined);
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnFriendInviteRejected(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerDeclined); // After a friend invite has been rejected this event is triggered
*/ UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnFriendInviteRejected(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &PlayerDeclined);
//*** Removed By Friend ***// */
/*FOnFriendRemovedDelegate RemovedByFriendDelegate;
FDelegateHandle RemovedByFriendDelegateHandle; //*** Removed By Friend ***//
/*FOnFriendRemovedDelegate RemovedByFriendDelegate;
void OnRemovedByFriendDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &FriendRemoved); FDelegateHandle RemovedByFriendDelegateHandle;
// After a friend removed the player this event is triggered void OnRemovedByFriendDelegateMaster(const FUniqueNetId& LocalPlayer, const FUniqueNetId &FriendRemoved);
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnRemovedByFriend(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendRemoved);*/ // After a friend removed the player this event is triggered
}; UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
void OnRemovedByFriend(const FBPUniqueNetId &InvitedPlayer, const FBPUniqueNetId &FriendRemoved);*/
};

View File

@@ -1,56 +1,56 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "OnlineSessionSettings.h" #include "OnlineSessionSettings.h"
#include "UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "AdvancedFriendsInterface.generated.h" #include "AdvancedFriendsInterface.generated.h"
UINTERFACE(MinimalAPI) UINTERFACE(MinimalAPI)
class UAdvancedFriendsInterface : public UInterface class UAdvancedFriendsInterface : public UInterface
{ {
GENERATED_UINTERFACE_BODY() GENERATED_UINTERFACE_BODY()
}; };
class IAdvancedFriendsInterface class IAdvancedFriendsInterface
{ {
GENERATED_IINTERFACE_BODY() GENERATED_IINTERFACE_BODY()
public: public:
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect // Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteReceived")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteReceived"))
void OnSessionInviteReceived(FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SearchResult); void OnSessionInviteReceived(FBPUniqueNetId PersonInviting, const FBlueprintSessionResult& SearchResult);
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect // Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteAccepted")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnSessionInviteAccepted"))
void OnSessionInviteAccepted(FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SearchResult); void OnSessionInviteAccepted(FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SearchResult);
// Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect // Called when the designated LocalUser has accepted a session invite, use JoinSession on result to connect
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerVoiceStateChanged")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerVoiceStateChanged"))
void OnPlayerVoiceStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking); void OnPlayerVoiceStateChanged(FBPUniqueNetId PlayerId, bool bIsTalking);
// Called when the designated LocalUser has changed login state // Called when the designated LocalUser has changed login state
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginChanged")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginChanged"))
void OnPlayerLoginChanged(int32 PlayerNum); void OnPlayerLoginChanged(int32 PlayerNum);
// Called when the designated LocalUser has changed login state // Called when the designated LocalUser has changed login state
UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginStatusChanged")) UFUNCTION(BlueprintImplementableEvent, meta = (DisplayName = "OnPlayerLoginStatusChanged"))
void OnPlayerLoginStatusChanged(EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId PlayerUniqueNetID); void OnPlayerLoginStatusChanged(EBPLoginStatus PreviousStatus, EBPLoginStatus NewStatus, FBPUniqueNetId PlayerUniqueNetID);
// REMOVED BECAUSE IT WAS NEVER BEING CALLED // REMOVED BECAUSE IT WAS NEVER BEING CALLED
// Called when the designated LocalUser has received a session invite, use JoinSession on result to connect // Called when the designated LocalUser has received a session invite, use JoinSession on result to connect
//UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "OnSessionInviteReceived")) //UFUNCTION(BlueprintImplementableEvent, meta = (FriendlyName = "OnSessionInviteReceived"))
//void OnSessionInviteReceived(const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session); //void OnSessionInviteReceived(const FBPUniqueNetId &FriendInviting, const FBlueprintSessionResult &Session);
}; };

View File

@@ -1,56 +1,56 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedFriendsLibrary.generated.h" #include "AdvancedFriendsLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedFriendsLog, Log, All);
UCLASS() UCLASS()
class UAdvancedFriendsLibrary : public UBlueprintFunctionLibrary class UAdvancedFriendsLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Friend List Functions *************// //********* Friend List Functions *************//
// Sends an Invite to the current online session to a list of friends // Sends an Invite to the current online session to a list of friends
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
static void SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result); static void SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result);
// Sends an Invite to the current online session to a friend // Sends an Invite to the current online session to a friend
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList", meta = (ExpandEnumAsExecs = "Result"))
static void SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result); static void SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result);
// Get a friend from the previously read/saved friends list (Must Call GetFriends first for this to return anything) // Get a friend from the previously read/saved friends list (Must Call GetFriends first for this to return anything)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList")
static void GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend); static void GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend);
// Get the previously read/saved friends list (Must Call GetFriends first for this to return anything) // Get the previously read/saved friends list (Must Call GetFriends first for this to return anything)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|FriendsList")
static void GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList); static void GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList);
// Get the previously read/saved recent players list (Must Call GetRecentPlayers first for this to return anything) // Get the previously read/saved recent players list (Must Call GetRecentPlayers first for this to return anything)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|RecentPlayersList") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|RecentPlayersList")
static void GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList); static void GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList);
// Check if a UniqueNetId is a friend // Check if a UniqueNetId is a friend
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|FriendsList") UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|FriendsList")
static void IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend); static void IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend);
}; };

View File

@@ -0,0 +1,71 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "Online.h"
#include "OnlineSubsystem.h"
#include "Engine/GameInstance.h"
#include "GameFramework/GameModeBase.h"
#include "GameFramework/GameSession.h"
#include "GameFramework/PlayerState.h"
//#include "UObjectIterator.h"
#include "AdvancedGameSession.generated.h"
/**
A quick wrapper around the game session to add a partial ban implementation. Just bans for the duration of the current session
*/
UCLASS(config = Game, notplaceable)
class AAdvancedGameSession : public AGameSession
{
GENERATED_UCLASS_BODY()
public:
UPROPERTY(Transient)
TMap<FUniqueNetIdRepl, FText> BanList;
virtual bool BanPlayer(class APlayerController* BannedPlayer, const FText& BanReason)
{
if (APlayerState* PlayerState = (BannedPlayer != NULL) ? BannedPlayer->PlayerState : NULL)
{
FUniqueNetIdRepl UniqueNetID = PlayerState->GetUniqueId();
bool bWasKicked = KickPlayer(BannedPlayer, BanReason);
if (bWasKicked)
{
BanList.Add(UniqueNetID, BanReason);
}
return bWasKicked;
}
return false;
}
// This should really be handled in the game mode asking game session, but I didn't want to force a custom game session AND game mode
// If done in the game mode, we could check prior to actually spooling up any player information in ApproveLogin
virtual void PostLogin(APlayerController* NewPlayer) override
{
if (APlayerState* PlayerState = (NewPlayer != NULL) ? NewPlayer->PlayerState : NULL)
{
FUniqueNetIdRepl UniqueNetID = PlayerState->GetUniqueId();
if (BanList.Contains(UniqueNetID))
{
KickPlayer(NewPlayer, BanList[UniqueNetID]);
}
}
}
};
AAdvancedGameSession::AAdvancedGameSession(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}

View File

@@ -1,81 +1,81 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineIdentityInterface.h" #include "Interfaces/OnlineIdentityInterface.h"
#include "OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedIdentityLibrary.generated.h" #include "AdvancedIdentityLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedIdentityLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedIdentityLog, Log, All);
UCLASS() UCLASS()
class UAdvancedIdentityLibrary : public UBlueprintFunctionLibrary class UAdvancedIdentityLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Identity Functions *************// //********* Identity Functions *************//
// Get the login status of a local player // Get the login status of a local player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result); static void GetLoginStatus(UObject* WorldContextObject, const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result);
// Get the auth token for a local player // Get the auth token for a local player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result); static void GetPlayerAuthToken(UObject* WorldContextObject, APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result);
// Get a players nickname // Get a players nickname
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity", meta = (WorldContext = "WorldContextObject"))
static void GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname); static void GetPlayerNickname(UObject* WorldContextObject, const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname);
//********* User Account Functions *************// //********* User Account Functions *************//
// Get a users account // Get a users account
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result); static void GetUserAccount(UObject* WorldContextObject, const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result);
// Get all known users accounts // Get all known users accounts
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result); static void GetAllUserAccounts(UObject* WorldContextObject, TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result);
// Get a user account access token // Get a user account access token
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken); static void GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken);
// Get a user account Auth attribute (depends on subsystem) // Get a user account Auth attribute (depends on subsystem)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result); static void GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result);
// Set a user account attribute (depends on subsystem) // Set a user account attribute (depends on subsystem)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result); static void SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result);
// Get user ID // Get user ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID); static void GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID);
// Get user accounts real name if possible // Get user accounts real name if possible
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName); static void GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName);
// Get user account display name if possible // Get user account display name if possible
UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount") UFUNCTION(BlueprintPure, Category = "Online|AdvancedIdentity|UserAccount")
static void GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName); static void GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName);
// Get user account attribute (depends on subsystem) // Get user account attribute (depends on subsystem)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedIdentity|UserAccount", meta = (ExpandEnumAsExecs = "Result"))
static void GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result); static void GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result);
}; };

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include "ModuleManager.h" #include "Modules/ModuleManager.h"
class AdvancedSessions : public IModuleInterface class AdvancedSessions : public IModuleInterface
{ {
public: public:
/** IModuleInterface implementation */ /** IModuleInterface implementation */
void StartupModule(); void StartupModule();
void ShutdownModule(); void ShutdownModule();
}; };

View File

@@ -2,18 +2,22 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "UObjectIterator.h" #include "GameFramework/GameModeBase.h"
#include "GameFramework/GameSession.h"
//#include "UObjectIterator.h"
#include "AdvancedSessionsLibrary.generated.h" #include "AdvancedSessionsLibrary.generated.h"
@@ -27,6 +31,17 @@ class UAdvancedSessionsLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Session Admin Functions *************//
// Kick a player from the currently active game session, only available on the server
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
static bool KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason);
// Ban a player from the currently active game session, only available on the server
// Note that the default gamesession class does not implement an actual ban list and just kicks when this is called
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
static bool BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason);
//********* Session Search Functions *************// //********* Session Search Functions *************//
// Adds or modifies session settings in an existing array depending on if they exist already or not // Adds or modifies session settings in an existing array depending on if they exist already or not
@@ -38,16 +53,16 @@ public:
static void GetExtraSettings(FBlueprintSessionResult SessionResult, TArray<FSessionPropertyKeyPair> & ExtraSettings); static void GetExtraSettings(FBlueprintSessionResult SessionResult, TArray<FSessionPropertyKeyPair> & ExtraSettings);
// Get the current session state // Get the current session state
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
static void GetSessionState(EBPOnlineSessionState &SessionState); static void GetSessionState(UObject* WorldContextObject, EBPOnlineSessionState &SessionState);
// Get the current session settings // Get the current session settings
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
static void GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result); static void GetSessionSettings(UObject* WorldContextObject, int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result);
// Check if someone is in the current session // Check if someone is in the current session
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
static void IsPlayerInSession(const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession); static void IsPlayerInSession(UObject* WorldContextObject, const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession);
// Make a literal session search parameter // Make a literal session search parameter
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
@@ -60,6 +75,14 @@ public:
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static bool IsValidSession(const FBlueprintSessionResult & SessionResult); static bool IsValidSession(const FBlueprintSessionResult & SessionResult);
// Get a string copy of a session ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static void GetSessionID_AsString(const FBlueprintSessionResult & SessionResult, FString& SessionID);
// Get a string copy of the current session ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
static void GetCurrentSessionID_AsString(UObject* WorldContextObject, FString& SessionID);
// Get the Unique Current Build ID // Get the Unique Current Build ID
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static void GetCurrentUniqueBuildID(int32 &UniqueBuildId); static void GetCurrentUniqueBuildID(int32 &UniqueBuildId);
@@ -67,12 +90,32 @@ public:
// Get the Unique Build ID from a session search result // Get the Unique Build ID from a session search result
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
static void GetUniqueBuildID(FBlueprintSessionResult SessionResult, int32 &UniqueBuildId); static void GetUniqueBuildID(FBlueprintSessionResult SessionResult, int32 &UniqueBuildId);
// Thanks CriErr for submission
// Get session property Key Name value
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
static FName GetSessionPropertyKey(const FSessionPropertyKeyPair& SessionProperty);
// Find session property by Name
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result"))
static void FindSessionPropertyByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingsName, EBlueprintResultSwitch &Result, FSessionPropertyKeyPair& OutProperty);
// Find session property index by Name
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result"))
static void FindSessionPropertyIndexByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingName, EBlueprintResultSwitch &Result, int32& OutIndex);
/// Removed the Index_None part of the last function, that isn't accessible in blueprint, better to return success/failure
// End Thanks CriErr :p
// Get session custom information key/value as Byte (For Enums) // Get session custom information key/value as Byte (For Enums)
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue); static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue);
// Get session custom information key/value as Bool // Get session custom information key/value as Bool
// Steam only currently supports Int,Float,String,BYTE values for search filtering!!!
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult")) UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue); static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue);
@@ -94,6 +137,7 @@ public:
static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value); static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value);
// Make a literal session custom information key/value pair from Bool // Make a literal session custom information key/value pair from Bool
// Steam only currently supports Int,Float,String,BYTE values for search filtering!
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value); static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value);
@@ -128,6 +172,10 @@ public:
UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal Unique Net ID", CompactNodeTitle = "==", Keywords = "== equal"), Category = "Online|AdvancedSessions|PlayerInfo|PlayerID") UFUNCTION(BlueprintPure, meta = (DisplayName = "Equal Unique Net ID", CompactNodeTitle = "==", Keywords = "== equal"), Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
static bool EqualEqual_UNetIDUnetID(const FBPUniqueNetId &A, const FBPUniqueNetId &B); static bool EqualEqual_UNetIDUnetID(const FBPUniqueNetId &A, const FBPUniqueNetId &B);
/** Converts a FBPUniqueNetID into a FUniqueNetID_Repl */
UFUNCTION(BlueprintPure, meta = (DisplayName = "ToUniqueNetIDRepl (Unique Net ID)", CompactNodeTitle = "->", BlueprintAutocast), Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
static FUniqueNetIdRepl Conv_BPUniqueIDToUniqueNetIDRepl(const FBPUniqueNetId& InUniqueID);
// Check if a UniqueNetId is a friend // Check if a UniqueNetId is a friend
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|UniqueNetId") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|UniqueNetId")
static void UniqueNetIdToString(const FBPUniqueNetId &UniqueNetId, FString &String); static void UniqueNetIdToString(const FBPUniqueNetId &UniqueNetId, FString &String);
@@ -156,5 +204,10 @@ public:
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc") UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
static bool HasOnlineSubsystem(FName SubSystemName); static bool HasOnlineSubsystem(FName SubSystemName);
//**** Seamless travel Functions ****//
//Exposes Server travel to blueprint
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Online|AdvancedSessions|Seamless", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
static bool ServerTravel(UObject* WorldContextObject, const FString& InURL, bool bAbsolute, bool bShouldSkipGameNotify);
}; };

View File

@@ -1,97 +1,99 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "VoiceInterface.h" #include "Interfaces/VoiceInterface.h"
//#include "OnlineFriendsInterface.h" //#include "OnlineFriendsInterface.h"
//#include "OnlineUserInterface.h" //#include "OnlineUserInterface.h"
//#include "OnlineMessageInterface.h" //#include "OnlineMessageInterface.h"
//#include "OnlinePresenceInterface.h" //#include "OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
//#include "OnlineSessionInterface.h" //#include "OnlineSessionInterface.h"
#include "UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedVoiceLibrary.generated.h" #include "AdvancedVoiceLibrary.generated.h"
//General Advanced Sessions Log //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedVoiceLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedVoiceLog, Log, All);
UCLASS() UCLASS()
class UAdvancedVoiceLibrary : public UBlueprintFunctionLibrary class UAdvancedVoiceLibrary : public UBlueprintFunctionLibrary
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
//********* Voice Library Functions *************// //********* Voice Library Functions *************//
// Get if a headset is present for the specified local user // Get if a headset is present for the specified local user
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo") UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
static void IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum = 0); static void IsHeadsetPresent(UObject* WorldContextObject, bool & bHasHeadset, uint8 LocalPlayerNum = 0);
// Starts networked voice, allows push to talk in coordination with StopNetworkedVoice // Starts networked voice, allows push to talk in coordination with StopNetworkedVoice
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void StartNetworkedVoice(uint8 LocalPlayerNum = 0); static void StartNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// Stops networked voice, allows push to talk in coordination with StartNetworkedVoice // Stops networked voice, allows push to talk in coordination with StartNetworkedVoice
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void StopNetworkedVoice(uint8 LocalPlayerNum = 0); static void StopNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// Registers a local player as someone interested in voice data // Registers a local player as someone interested in voice data
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static bool RegisterLocalTalker(uint8 LocalPlayerNum = 0); static bool RegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// Registers all signed in players as local talkers // Registers all signed in players as local talkers
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") // This is already done automatically, only do it manually if you unregistered someone
static void RegisterAllLocalTalkers(); UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void RegisterAllLocalTalkers(UObject* WorldContextObject);
// UnRegisters local player as a local talker
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") // UnRegisters local player as a local talker
static void UnRegisterLocalTalker(uint8 LocalPlayerNum = 0); UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void UnRegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum = 0);
// UnRegisters all signed in players as local talkers
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") // UnRegisters all signed in players as local talkers
static void UnRegisterAllLocalTalkers(); UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
static void UnRegisterAllLocalTalkers(UObject* WorldContextObject);
// Registers a remote player as a talker
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice") // Registers a remote player as a talker
static bool RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId); // This is already done automatically, only do it manually if you unregistered someone
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
// UnRegisters a remote player as a talker static bool RegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId);
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId); // UnRegisters a remote player as a talker
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
// UnRegisters all remote players as talkers static bool UnRegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId);
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static void RemoveAllRemoteTalkers(); // UnRegisters all remote players as talkers
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
// Returns whether a local player is currently talking static void RemoveAllRemoteTalkers(UObject* WorldContextObject);
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static bool IsLocalPlayerTalking(uint8 LocalPlayerNum); // Returns whether a local player is currently talking
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
// Returns whether a remote player is currently talking static bool IsLocalPlayerTalking(UObject* WorldContextObject, uint8 LocalPlayerNum);
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static bool IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId); // Returns whether a remote player is currently talking
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
// Returns whether a player is muted for the specified local player static bool IsRemotePlayerTalking(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId);
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static bool IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId); // Returns whether a player is muted for the specified local player
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
// Mutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to mute globally for the player static bool IsPlayerMuted(UObject* WorldContextObject, uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId);
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false); // Mutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to mute globally for the player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
// UnMutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to unmute globally for the player static bool MuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
static bool UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false); // UnMutes the player associated with the uniquenetid for the specified local player, if IsSystemWide is true then it will attempt to unmute globally for the player
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice", meta = (WorldContext = "WorldContextObject"))
// Gets the number of local talkers for this system static bool UnMuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide = false);
UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo")
static void GetNumLocalTalkers(int32 & NumLocalTalkers); // Gets the number of local talkers for this system
}; UFUNCTION(BlueprintPure, Category = "Online|AdvancedVoice|VoiceInfo", meta = (WorldContext = "WorldContextObject"))
static void GetNumLocalTalkers(UObject* WorldContextObject, int32 & NumLocalTalkers);
};

View File

@@ -0,0 +1,55 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "Interfaces/OnlineIdentityInterface.h"
#include "Engine/LocalPlayer.h"
#include "AutoLoginUserCallbackProxy.generated.h"
UCLASS(MinimalAPI)
class UAutoLoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase
{
GENERATED_UCLASS_BODY()
// Called when there is a successful destroy
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnSuccess;
// Called when there is an unsuccessful destroy
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure;
/**
* Logs the player into the online service using parameters passed on the
* command line. Expects -AUTH_LOGIN=<UserName> -AUTH_PASSWORD=<password>. If either
* are missing, the function returns false and doesn't start the login
* process
*
* @param LocalUserNum the controller number of the associated user
*
*/
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity")
static UAutoLoginUserCallbackProxy* AutoLoginUser(UObject* WorldContextObject, int32 LocalUserNum);
// UOnlineBlueprintCallProxyBase interface
virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface
private:
// Internal callback when the operation completes, calls out to the public success/failure callbacks
void OnCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& ErrorVal);
private:
// The controller number of the associated user
int32 LocalUserNumber;
// The delegate executed by the online subsystem
FOnLoginCompleteDelegate Delegate;
// Handle to the registered OnDestroySessionComplete delegate
FDelegateHandle DelegateHandle;
// The world context object in which this call is taking place
TWeakObjectPtr<UObject> WorldContextObject;
};

View File

@@ -1,408 +1,435 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "EngineMinimal.h" //#include "EngineMinimal.h"
#include "Engine/Engine.h" #include "Engine/Engine.h"
#include "GameFramework/PlayerState.h" #include "GameFramework/PlayerState.h"
#include "Core.h" //#include "Core.h"
#include "OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "OnlineSessionSettings.h" #include "OnlineSessionSettings.h"
#include "OnlineDelegateMacros.h" #include "OnlineDelegateMacros.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineSubsystemImpl.h" #include "OnlineSubsystemImpl.h"
#include "OnlineSubsystemUtils.h" #include "OnlineSubsystemUtils.h"
#include "OnlineSubsystemUtilsModule.h" #include "OnlineSubsystemUtilsModule.h"
#include "ModuleManager.h" #include "GameFramework/PlayerController.h"
#include "OnlineSubsystemUtilsClasses.h" #include "Modules/ModuleManager.h"
#include "BlueprintDataDefinitions.generated.h" #include "OnlineSubsystemUtilsClasses.h"
#include "BlueprintDataDefinitions.generated.h"
UENUM(BlueprintType)
enum class EBPUserPrivileges : uint8 UENUM(BlueprintType)
{ enum class EBPUserPrivileges : uint8
/** Whether the user can play at all, online or offline - may be age restricted */ {
CanPlay, /** Whether the user can play at all, online or offline - may be age restricted */
/** Whether the user can play in online modes */ CanPlay,
CanPlayOnline, /** Whether the user can play in online modes */
/** Whether the user can use voice and text chat */ CanPlayOnline,
CanCommunicateOnline, /** Whether the user can use voice and text chat */
/** Whether the user can use content generated by other users */ CanCommunicateOnline,
CanUseUserGeneratedContent /** Whether the user can use content generated by other users */
}; CanUseUserGeneratedContent
};
UENUM(BlueprintType)
enum class EBPLoginStatus : uint8 UENUM(BlueprintType)
{ enum class EBPLoginStatus : uint8
/** Player has not logged in or chosen a local profile */ {
NotLoggedIn, /** Player has not logged in or chosen a local profile */
/** Player is using a local profile but is not logged in */ NotLoggedIn,
UsingLocalProfile, /** Player is using a local profile but is not logged in */
/** Player has been validated by the platform specific authentication service */ UsingLocalProfile,
LoggedIn /** Player has been validated by the platform specific authentication service */
}; LoggedIn
};
USTRUCT(BlueprintType)
struct FBPUserOnlineAccount USTRUCT(BlueprintType)
{ struct FBPUserOnlineAccount
GENERATED_USTRUCT_BODY() {
GENERATED_USTRUCT_BODY()
public:
TSharedPtr<FUserOnlineAccount> UserAccountInfo; public:
TSharedPtr<FUserOnlineAccount> UserAccountInfo;
FBPUserOnlineAccount()
{ FBPUserOnlineAccount()
{
}
}
FBPUserOnlineAccount(TSharedPtr<FUserOnlineAccount> UserAccount)
{ FBPUserOnlineAccount(TSharedPtr<FUserOnlineAccount> UserAccount)
UserAccountInfo = UserAccount; {
} UserAccountInfo = UserAccount;
}; }
};
UENUM()
enum class ESessionSettingSearchResult : uint8 UENUM()
{ enum class ESessionSettingSearchResult : uint8
// Found the setting {
Found, // Found the setting
Found,
// Did not find the setting
NotFound, // Did not find the setting
NotFound,
// Was not the correct type
WrongType // Was not the correct type
}; WrongType
};
// This makes a lot of the blueprint functions cleaner
UENUM() // This makes a lot of the blueprint functions cleaner
enum class EBlueprintResultSwitch : uint8 UENUM()
{ enum class EBlueprintResultSwitch : uint8
// On Success {
OnSuccess, // On Success
OnSuccess,
// On Failure
OnFailure // On Failure
}; OnFailure
};
// This makes a lot of the blueprint functions cleaner
UENUM() // This makes a lot of the blueprint functions cleaner
enum class EBlueprintAsyncResultSwitch : uint8 UENUM()
{ enum class EBlueprintAsyncResultSwitch : uint8
// On Success {
OnSuccess, // On Success
OnSuccess,
// Still loading
AsyncLoading, // Still loading
// On Failure AsyncLoading,
OnFailure // On Failure
}; OnFailure
};
// This is to define server type searches
UENUM(BlueprintType) // This is to define server type searches
enum class EBPServerPresenceSearchType : uint8 UENUM(BlueprintType)
{ enum class EBPServerPresenceSearchType : uint8
AllServers, {
ClientServersOnly, AllServers,
DedicatedServersOnly ClientServersOnly,
}; DedicatedServersOnly
};
// Wanted this to be switchable in the editor
UENUM(BlueprintType) // Wanted this to be switchable in the editor
enum class EBPOnlinePresenceState : uint8 UENUM(BlueprintType)
{ enum class EBPOnlinePresenceState : uint8
Online, {
Offline, Online,
Away, Offline,
ExtendedAway, Away,
DoNotDisturb, ExtendedAway,
Chat DoNotDisturb,
}; Chat
};
UENUM(BlueprintType)
enum class EBPOnlineSessionState : uint8 UENUM(BlueprintType)
{ enum class EBPOnlineSessionState : uint8
/** An online session has not been created yet */ {
NoSession, /** An online session has not been created yet */
/** An online session is in the process of being created */ NoSession,
Creating, /** An online session is in the process of being created */
/** Session has been created but the session hasn't started (pre match lobby) */ Creating,
Pending, /** Session has been created but the session hasn't started (pre match lobby) */
/** Session has been asked to start (may take time due to communication with backend) */ Pending,
Starting, /** Session has been asked to start (may take time due to communication with backend) */
/** The current session has started. Sessions with join in progress disabled are no longer joinable */ Starting,
InProgress, /** The current session has started. Sessions with join in progress disabled are no longer joinable */
/** The session is still valid, but the session is no longer being played (post match lobby) */ InProgress,
Ending, /** The session is still valid, but the session is no longer being played (post match lobby) */
/** The session is closed and any stats committed */ Ending,
Ended, /** The session is closed and any stats committed */
/** The session is being destroyed */ Ended,
Destroying /** The session is being destroyed */
}; Destroying
};
// Boy oh boy is this a dirty hack, but I can't figure out a good way to do it otherwise at the moment
// The UniqueNetId is an abstract class so I can't exactly re-initialize it to make a shared pointer on some functions // Boy oh boy is this a dirty hack, but I can't figure out a good way to do it otherwise at the moment
// So I made the blueprintable UniqueNetID into a dual variable struct with access functions and I am converting the const var for the pointer // The UniqueNetId is an abstract class so I can't exactly re-initialize it to make a shared pointer on some functions
// I really need to re-think this later // So I made the blueprintable UniqueNetID into a dual variable struct with access functions and I am converting the const var for the pointer
USTRUCT(BlueprintType) // I really need to re-think this later
struct FBPUniqueNetId USTRUCT(BlueprintType)
{ struct FBPUniqueNetId
GENERATED_USTRUCT_BODY() {
GENERATED_USTRUCT_BODY()
private:
bool bUseDirectPointer; private:
bool bUseDirectPointer;
public:
TSharedPtr<const FUniqueNetId> UniqueNetId; public:
const FUniqueNetId * UniqueNetIdPtr; TSharedPtr<const FUniqueNetId> UniqueNetId;
const FUniqueNetId * UniqueNetIdPtr;
void SetUniqueNetId(const TSharedPtr<const FUniqueNetId> &ID)
{ void SetUniqueNetId(const TSharedPtr<const FUniqueNetId> &ID)
bUseDirectPointer = false; {
UniqueNetIdPtr = nullptr; bUseDirectPointer = false;
UniqueNetId = ID; UniqueNetIdPtr = nullptr;
} UniqueNetId = ID;
}
void SetUniqueNetId(const FUniqueNetId *ID)
{ void SetUniqueNetId(const FUniqueNetId *ID)
bUseDirectPointer = true; {
UniqueNetIdPtr = ID; bUseDirectPointer = true;
} UniqueNetIdPtr = ID;
}
bool IsValid() const
{ bool IsValid() const
if (bUseDirectPointer && UniqueNetIdPtr != nullptr && UniqueNetIdPtr->IsValid()) {
{ if (bUseDirectPointer && UniqueNetIdPtr != nullptr && UniqueNetIdPtr->IsValid())
return true; {
} return true;
else if (UniqueNetId.IsValid()) }
{ else if (UniqueNetId.IsValid())
return true; {
} return true;
else }
return false; else
return false;
}
}
const FUniqueNetId* GetUniqueNetId() const
{ const FUniqueNetId* GetUniqueNetId() const
if (bUseDirectPointer && UniqueNetIdPtr != nullptr) {
{ if (bUseDirectPointer && UniqueNetIdPtr != nullptr)
// No longer converting to non const as all functions now pass const UniqueNetIds {
return /*const_cast<FUniqueNetId*>*/(UniqueNetIdPtr); // No longer converting to non const as all functions now pass const UniqueNetIds
} return /*const_cast<FUniqueNetId*>*/(UniqueNetIdPtr);
else if (UniqueNetId.IsValid()) }
{ else if (UniqueNetId.IsValid())
return UniqueNetId.Get(); {
} return UniqueNetId.Get();
else }
return nullptr; else
} return nullptr;
}
FBPUniqueNetId()
{ // Adding in a compare operator so that std functions will work with this struct
bUseDirectPointer = false; FORCEINLINE bool operator==(const FBPUniqueNetId& Other) const
UniqueNetIdPtr = nullptr; {
} return (IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId()));
}; }
USTRUCT(BluePrintType) FORCEINLINE bool operator!=(const FBPUniqueNetId& Other) const
struct FBPOnlineUser {
{ return !(IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId()));
GENERATED_USTRUCT_BODY() }
public: FBPUniqueNetId()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") {
FBPUniqueNetId UniqueNetId; bUseDirectPointer = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UniqueNetIdPtr = nullptr;
FString DisplayName; }
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") };
FString RealName;
}; USTRUCT(BluePrintType)
struct FBPOnlineUser
USTRUCT(BluePrintType) {
struct FBPOnlineRecentPlayer : public FBPOnlineUser GENERATED_USTRUCT_BODY()
{
GENERATED_USTRUCT_BODY() public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
public: FBPUniqueNetId UniqueNetId;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString LastSeen; FString DisplayName;
}; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString RealName;
};
USTRUCT(BlueprintType)
struct FBPFriendPresenceInfo USTRUCT(BluePrintType)
{ struct FBPOnlineRecentPlayer : public FBPOnlineUser
GENERATED_USTRUCT_BODY() {
GENERATED_USTRUCT_BODY()
public:
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsOnline; FString LastSeen;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") };
bool bIsPlaying;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlayingThisGame; USTRUCT(BlueprintType)
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") struct FBPFriendPresenceInfo
bool bIsJoinable; {
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") GENERATED_USTRUCT_BODY()
bool bHasVoiceSupport;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") public:
EBPOnlinePresenceState PresenceState;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FString StatusString; bool bIsOnline = false;
}; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlaying = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
bool bIsPlayingThisGame = false;
USTRUCT(BlueprintType) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
struct FBPFriendInfo bool bIsJoinable = false;
{ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
GENERATED_USTRUCT_BODY() bool bHasVoiceSupport = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
public: EBPOnlinePresenceState PresenceState = EBPOnlinePresenceState::Offline;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") FString StatusString;
FString DisplayName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") FBPFriendPresenceInfo()
FString RealName; {
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") bIsOnline = false;
EBPOnlinePresenceState OnlineState; bIsPlaying = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") bIsPlayingThisGame = false;
FBPUniqueNetId UniqueNetId; bIsJoinable = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") bHasVoiceSupport = false;
bool bIsPlayingSameGame; PresenceState = EBPOnlinePresenceState::Offline;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") }
FBPFriendPresenceInfo PresenceInfo; };
};
USTRUCT(BlueprintType)
/** The types of comparison operations for a given search query */ struct FBPFriendInfo
// Used to compare session properties {
UENUM(BlueprintType) GENERATED_USTRUCT_BODY()
enum class EOnlineComparisonOpRedux : uint8
{ public:
Equals,
NotEquals, UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
GreaterThan, FString DisplayName;
GreaterThanEquals, UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
LessThan, FString RealName;
LessThanEquals, UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
}; EBPOnlinePresenceState OnlineState = EBPOnlinePresenceState::Offline;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
FBPUniqueNetId UniqueNetId;
// Used to store session properties before converting to FVariantData UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
USTRUCT(BlueprintType) bool bIsPlayingSameGame = false;
struct FSessionPropertyKeyPair UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
{ FBPFriendPresenceInfo PresenceInfo;
GENERATED_USTRUCT_BODY()
FBPFriendInfo()
FName Key; {
FVariantData Data; OnlineState = EBPOnlinePresenceState::Offline;
}; bIsPlayingSameGame = false;
}
};
// Sent to the FindSessionsAdvanced to filter the end results
USTRUCT(BlueprintType)
struct FSessionsSearchSetting /** The types of comparison operations for a given search query */
{ // Used to compare session properties
GENERATED_USTRUCT_BODY() UENUM(BlueprintType)
//UPROPERTY() enum class EOnlineComparisonOpRedux : uint8
{
Equals,
// Had to make a copy of this to account for the original not being exposed to blueprints NotEquals,
/** How is this session setting compared on the backend searches */ GreaterThan,
EOnlineComparisonOpRedux ComparisonOp; GreaterThanEquals,
LessThan,
// The key pair to search for LessThanEquals,
FSessionPropertyKeyPair PropertyKeyPair; };
};
// Couldn't use the default one as it is not exposed to other modules, had to re-create it here // Used to store session properties before converting to FVariantData
// Helper class for various methods to reduce the call hierarchy USTRUCT(BlueprintType)
struct FOnlineSubsystemBPCallHelperAdvanced struct FSessionPropertyKeyPair
{ {
public: GENERATED_USTRUCT_BODY()
FOnlineSubsystemBPCallHelperAdvanced(const TCHAR* CallFunctionContext, UWorld* World, FName SystemName = NAME_None)
: OnlineSub(Online::GetSubsystem(World, SystemName)) FName Key;
, FunctionContext(CallFunctionContext) FVariantData Data;
{ };
if (OnlineSub == nullptr)
{
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid or uninitialized OnlineSubsystem"), FunctionContext), ELogVerbosity::Warning); // Sent to the FindSessionsAdvanced to filter the end results
} USTRUCT(BlueprintType)
} struct FSessionsSearchSetting
{
void QueryIDFromPlayerController(APlayerController* PlayerController) GENERATED_USTRUCT_BODY()
{ //UPROPERTY()
UserID.Reset();
//return const_cast<FUniqueNetId*>(UniqueNetIdPtr);
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL) // Had to make a copy of this to account for the original not being exposed to blueprints
{ /** How is this session setting compared on the backend searches */
UserID = PlayerState->UniqueId.GetUniqueNetId(); EOnlineComparisonOpRedux ComparisonOp;
if (!UserID.IsValid())
{ // The key pair to search for
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning); FSessionPropertyKeyPair PropertyKeyPair;
} };
}
else // Couldn't use the default one as it is not exposed to other modules, had to re-create it here
{ // Helper class for various methods to reduce the call hierarchy
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid player state"), FunctionContext), ELogVerbosity::Warning); struct FOnlineSubsystemBPCallHelperAdvanced
} {
} public:
FOnlineSubsystemBPCallHelperAdvanced(const TCHAR* CallFunctionContext, UWorld* World, FName SystemName = NAME_None)
: OnlineSub(Online::GetSubsystem(World, SystemName))
bool IsValid() const , FunctionContext(CallFunctionContext)
{ {
return UserID.IsValid() && (OnlineSub != nullptr); if (OnlineSub == nullptr)
} {
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid or uninitialized OnlineSubsystem"), FunctionContext), ELogVerbosity::Warning);
public: }
//TSharedPtr<const FUniqueNetId>& GetUniqueNetId() }
TSharedPtr</*class*/ const FUniqueNetId> UserID;
IOnlineSubsystem* const OnlineSub; void QueryIDFromPlayerController(APlayerController* PlayerController)
const TCHAR* FunctionContext; {
}; UserID.Reset();
class FOnlineSearchSettingsEx : public FOnlineSearchSettings //return const_cast<FUniqueNetId*>(UniqueNetIdPtr);
{ if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
/** {
* Sets a key value pair combination that defines a search parameter UserID = PlayerState->GetUniqueId().GetUniqueNetId();
* if (!UserID.IsValid())
* @param Key key for the setting {
* @param Value value of the setting FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning);
* @param InType type of comparison }
*/ }
public: else
{
void HardSet(FName Key, const FVariantData& Value, EOnlineComparisonOpRedux CompOp) FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Invalid player state"), FunctionContext), ELogVerbosity::Warning);
{ }
FOnlineSessionSearchParam* SearchParam = SearchParams.Find(Key); }
TEnumAsByte<EOnlineComparisonOp::Type> op;
bool IsValid() const
switch (CompOp) {
{ return UserID.IsValid() && (OnlineSub != nullptr);
case EOnlineComparisonOpRedux::Equals: op = EOnlineComparisonOp::Equals; break; }
case EOnlineComparisonOpRedux::GreaterThan: op = EOnlineComparisonOp::GreaterThan; break;
case EOnlineComparisonOpRedux::GreaterThanEquals: op = EOnlineComparisonOp::GreaterThanEquals; break; public:
case EOnlineComparisonOpRedux::LessThan: op = EOnlineComparisonOp::LessThan; break; //TSharedPtr<const FUniqueNetId>& GetUniqueNetId()
case EOnlineComparisonOpRedux::LessThanEquals: op = EOnlineComparisonOp::LessThanEquals; break; TSharedPtr</*class*/ const FUniqueNetId> UserID;
case EOnlineComparisonOpRedux::NotEquals: op = EOnlineComparisonOp::NotEquals; break; IOnlineSubsystem* const OnlineSub;
default: op = EOnlineComparisonOp::Equals; break; const TCHAR* FunctionContext;
} };
class FOnlineSearchSettingsEx : public FOnlineSearchSettings
if (SearchParam) {
{ /**
SearchParam->Data = Value; * Sets a key value pair combination that defines a search parameter
SearchParam->ComparisonOp = op; *
} * @param Key key for the setting
else * @param Value value of the setting
{ * @param InType type of comparison
FOnlineSessionSearchParam searchSetting((int)0, op); */
searchSetting.Data = Value; public:
SearchParams.Add(Key, searchSetting);
} void HardSet(FName Key, const FVariantData& Value, EOnlineComparisonOpRedux CompOp)
} {
}; FOnlineSessionSearchParam* SearchParam = SearchParams.Find(Key);
TEnumAsByte<EOnlineComparisonOp::Type> op;
switch (CompOp)
{
case EOnlineComparisonOpRedux::Equals: op = EOnlineComparisonOp::Equals; break;
case EOnlineComparisonOpRedux::GreaterThan: op = EOnlineComparisonOp::GreaterThan; break;
case EOnlineComparisonOpRedux::GreaterThanEquals: op = EOnlineComparisonOp::GreaterThanEquals; break;
case EOnlineComparisonOpRedux::LessThan: op = EOnlineComparisonOp::LessThan; break;
case EOnlineComparisonOpRedux::LessThanEquals: op = EOnlineComparisonOp::LessThanEquals; break;
case EOnlineComparisonOpRedux::NotEquals: op = EOnlineComparisonOp::NotEquals; break;
default: op = EOnlineComparisonOp::Equals; break;
}
if (SearchParam)
{
SearchParam->Data = Value;
SearchParam->ComparisonOp = op;
}
else
{
FOnlineSessionSearchParam searchSetting((int)0, op);
searchSetting.Data = Value;
SearchParams.Add(Key, searchSetting);
}
}
};
#define INVALID_INDEX -1 #define INVALID_INDEX -1

View File

@@ -1,7 +1,8 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "OnlineSessionInterface.h" #include "Engine/Engine.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "CancelFindSessionsCallbackProxy.generated.h" #include "CancelFindSessionsCallbackProxy.generated.h"
@@ -41,5 +42,5 @@ private:
FDelegateHandle DelegateHandle; FDelegateHandle DelegateHandle;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -2,6 +2,7 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "CreateSessionCallbackProxyAdvanced.generated.h" #include "CreateSessionCallbackProxyAdvanced.generated.h"
@@ -18,19 +19,28 @@ class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure; FEmptyOnlineDelegate OnFailure;
// Creates a session with the default online subsystem with advanced optional inputs, for dedicated servers leave UsePresence as false and set IsDedicatedServer to true. Dedicated servers don't use presence. /**
* Creates a session with the default online subsystem with advanced optional inputs, for dedicated servers leave UsePresence as false and set IsDedicatedServer to true. Dedicated servers don't use presence.
* @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection)
* @param bUseLAN When you want to play LAN, the level to play on must be loaded with option 'bIsLanMatch'
* @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server.
* @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it, generally true on steam for listen servers and false for dedicated
* @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible.
* @param bUseLobbiesVoiceChatIfAvailable Set to true to setup voice chat lobbies if the API supports it
* @param bStartAfterCreate Set to true to start the session after it's created. If false you need to manually call StartSession when ready.
*/
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true); static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair>& ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true, bool bUseLobbiesVoiceChatIfAvailable = false, bool bStartAfterCreate = true);
// UOnlineBlueprintCallProxyBase interface // UOnlineBlueprintCallProxyBase interface
virtual void Activate() override; virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface // End of UOnlineBlueprintCallProxyBase interface
private: private:
// Internal callback when session creation completes, calls StartSession // Internal callback when session creation completes, optionally calls StartSession
void OnCreateCompleted(FName SessionName, bool bWasSuccessful); void OnCreateCompleted(FName SessionName, bool bWasSuccessful);
// Internal callback when session creation completes, calls StartSession // Internal callback when session start completes
void OnStartCompleted(FName SessionName, bool bWasSuccessful); void OnStartCompleted(FName SessionName, bool bWasSuccessful);
// The player controller triggering things // The player controller triggering things
@@ -64,6 +74,9 @@ private:
// Whether to use the presence option // Whether to use the presence option
bool bUsePresence; bool bUsePresence;
// Whether to prefer the use of lobbies for hosting if the api supports them
bool bUseLobbiesIfAvailable;
// Whether to allow joining via presence // Whether to allow joining via presence
bool bAllowJoinViaPresence; bool bAllowJoinViaPresence;
@@ -79,10 +92,16 @@ private:
// Should advertise server? // Should advertise server?
bool bShouldAdvertise; bool bShouldAdvertise;
// Whether to prefer the use of voice chat lobbies if the api supports them
bool bUseLobbiesVoiceChatIfAvailable;
// Whether to start the session automatically after it is created
bool bStartAfterCreate;
// Store extra settings // Store extra settings
TArray<FSessionPropertyKeyPair> ExtraSettings; TArray<FSessionPropertyKeyPair> ExtraSettings;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -1,7 +1,8 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "OnlineSessionInterface.h" #include "Engine/Engine.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "EndSessionCallbackProxy.generated.h" #include "EndSessionCallbackProxy.generated.h"
@@ -18,8 +19,11 @@ class UEndSessionCallbackProxy : public UOnlineBlueprintCallProxyBase
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure; FEmptyOnlineDelegate OnFailure;
// Ends the current session /**
UFUNCTION(BlueprintCallable, meta=(DeprecatedFunction,DeprecationMessage = "This function is deprecated, I realized that people have been using it wrong and it doesn't have much use in blueprints. Use Destroy Session only instead.",BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions|Deprecated") * Ends the current sessions, Generally for almost all uses you should be using the engines native Destroy Session node instead.
* This exists for people using StartSession and optionally hand managing the session state.
*/
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions")
static UEndSessionCallbackProxy* EndSession(UObject* WorldContextObject, class APlayerController* PlayerController); static UEndSessionCallbackProxy* EndSession(UObject* WorldContextObject, class APlayerController* PlayerController);
// UOnlineBlueprintCallProxyBase interface // UOnlineBlueprintCallProxyBase interface
@@ -41,5 +45,5 @@ private:
FDelegateHandle DelegateHandle; FDelegateHandle DelegateHandle;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -1,51 +1,51 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "FindFriendSessionCallbackProxy.generated.h" #include "FindFriendSessionCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedFindFriendSessionLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedFindFriendSessionLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintFindFriendSessionDelegate, const TArray<FBlueprintSessionResult> &, SessionInfo); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintFindFriendSessionDelegate, const TArray<FBlueprintSessionResult> &, SessionInfo);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UFindFriendSessionCallbackProxy : public UOnlineBlueprintCallProxyBase class UFindFriendSessionCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintFindFriendSessionDelegate OnSuccess; FBlueprintFindFriendSessionDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintFindFriendSessionDelegate OnFailure; FBlueprintFindFriendSessionDelegate OnFailure;
// Attempts to get the current session that a friend is in // Attempts to get the current session that a friend is in
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static UFindFriendSessionCallbackProxy* FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId); static UFindFriendSessionCallbackProxy* FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo); void OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo);
// The player controller triggering things // The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The UniqueNetID of the person to invite // The UniqueNetID of the person to invite
FBPUniqueNetId cUniqueNetId; FBPUniqueNetId cUniqueNetId;
// The delegate to call on completion // The delegate to call on completion
FOnFindFriendSessionCompleteDelegate OnFindFriendSessionCompleteDelegate; FOnFindFriendSessionCompleteDelegate OnFindFriendSessionCompleteDelegate;
// Handles to the registered delegates above // Handles to the registered delegates above
FDelegateHandle FindFriendSessionCompleteDelegateHandle; FDelegateHandle FindFriendSessionCompleteDelegateHandle;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -1,11 +1,18 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "OnlineSessionInterface.h" #include "Engine/Engine.h"
#include "Interfaces/OnlineSessionInterface.h"
#include "FindSessionsCallbackProxy.h" #include "FindSessionsCallbackProxy.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "FindSessionsCallbackProxyAdvanced.generated.h" #include "FindSessionsCallbackProxyAdvanced.generated.h"
FORCEINLINE bool operator==(const FBlueprintSessionResult& A, const FBlueprintSessionResult& B)
{
return (A.OnlineResult.IsValid() == B.OnlineResult.IsValid() && (A.OnlineResult.GetSessionIdStr() == B.OnlineResult.GetSessionIdStr()));
}
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
{ {
@@ -21,7 +28,7 @@ class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
// Searches for advertised sessions with the default online subsystem and includes an array of filters // Searches for advertised sessions with the default online subsystem and includes an array of filters
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AutoCreateRefTerm="Filters"), Category = "Online|AdvancedSessions") UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AutoCreateRefTerm="Filters"), Category = "Online|AdvancedSessions")
static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, int MinSlotsAvailable = 0); static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, bool bSearchLobbies = true, int MinSlotsAvailable = 0);
static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator); static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator);
@@ -51,9 +58,9 @@ private:
// Internal callback when the session search completes, calls out to the public success/failure callbacks // Internal callback when the session search completes, calls out to the public success/failure callbacks
void OnCompleted(bool bSuccess); void OnCompleted(bool bSuccess);
bool bRunSecondSearch; bool bRunSecondSearch;
bool bIsOnSecondSearch; bool bIsOnSecondSearch;
TArray<FBlueprintSessionResult> SessionSearchResults; TArray<FBlueprintSessionResult> SessionSearchResults;
private: private:
@@ -91,9 +98,12 @@ private:
// Search for secure servers only // Search for secure servers only
bool bSecureServersOnly; bool bSecureServersOnly;
// Search through lobbies
bool bSearchLobbies;
// Min slots requires to search // Min slots requires to search
int MinSlotsAvailable; int MinSlotsAvailable;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -1,49 +1,49 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "GetFriendsCallbackProxy.generated.h" #include "GetFriendsCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetFriendsLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetFriendsLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetFriendsListDelegate, const TArray<FBPFriendInfo>&, Results); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetFriendsListDelegate, const TArray<FBPFriendInfo>&, Results);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UGetFriendsCallbackProxy : public UOnlineBlueprintCallProxyBase class UGetFriendsCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetFriendsListDelegate OnSuccess; FBlueprintGetFriendsListDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetFriendsListDelegate OnFailure; FBlueprintGetFriendsListDelegate OnFailure;
// Gets the players list of friends from the OnlineSubsystem and returns it, can be retrieved later with GetStoredFriendsList // Gets the players list of friends from the OnlineSubsystem and returns it, can be retrieved later with GetStoredFriendsList
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static UGetFriendsCallbackProxy* GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController); static UGetFriendsCallbackProxy* GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString); void OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString);
// The player controller triggering things // The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The delegate executed // The delegate executed
FOnReadFriendsListComplete FriendListReadCompleteDelegate; FOnReadFriendsListComplete FriendListReadCompleteDelegate;
// The Type of friends list to get // The Type of friends list to get
// Removed because all but the facebook interfaces don't even currently support anything but the default friends list. // Removed because all but the facebook interfaces don't even currently support anything but the default friends list.
//EBPFriendsLists FriendListToGet; //EBPFriendsLists FriendListToGet;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -1,49 +1,49 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "GetRecentPlayersCallbackProxy.generated.h" #include "GetRecentPlayersCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetRecentPlayersLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedGetRecentPlayersLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetRecentPlayersDelegate, const TArray<FBPOnlineRecentPlayer>&, Results); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintGetRecentPlayersDelegate, const TArray<FBPOnlineRecentPlayer>&, Results);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class UGetRecentPlayersCallbackProxy : public UOnlineBlueprintCallProxyBase class UGetRecentPlayersCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetRecentPlayersDelegate OnSuccess; FBlueprintGetRecentPlayersDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGetRecentPlayersDelegate OnFailure; FBlueprintGetRecentPlayersDelegate OnFailure;
// Gets the list of recent players from the OnlineSubsystem and returns it, can be retrieved later with GetStoredRecentPlayersList, can fail if no recent players are found // Gets the list of recent players from the OnlineSubsystem and returns it, can be retrieved later with GetStoredRecentPlayersList, can fail if no recent players are found
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static UGetRecentPlayersCallbackProxy* GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId &UniqueNetId); static UGetRecentPlayersCallbackProxy* GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId &UniqueNetId);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString); void OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString);
// Handle to the registered OnFindSessionsComplete delegate // Handle to the registered OnFindSessionsComplete delegate
FDelegateHandle DelegateHandle; FDelegateHandle DelegateHandle;
// The player controller triggering things // The player controller triggering things
//TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; //TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The UniqueNetID of the person to get recent players for // The UniqueNetID of the person to get recent players for
FBPUniqueNetId cUniqueNetId; FBPUniqueNetId cUniqueNetId;
// The delegate executed // The delegate executed
FOnQueryRecentPlayersCompleteDelegate QueryRecentPlayersCompleteDelegate; FOnQueryRecentPlayersCompleteDelegate QueryRecentPlayersCompleteDelegate;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -3,7 +3,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "OnlineIdentityInterface.h" #include "Interfaces/OnlineIdentityInterface.h"
#include "GetUserPrivilegeCallbackProxy.generated.h" #include "GetUserPrivilegeCallbackProxy.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FBlueprintGetUserPrivilegeDelegate,/* const &FBPUniqueNetId, PlayerID,*/ EBPUserPrivileges, QueriedPrivilege, bool, HadPrivilege); DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FBlueprintGetUserPrivilegeDelegate,/* const &FBPUniqueNetId, PlayerID,*/ EBPUserPrivileges, QueriedPrivilege, bool, HadPrivilege);
@@ -21,7 +21,7 @@ class UGetUserPrivilegeCallbackProxy : public UOnlineBlueprintCallProxyBase
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure; FEmptyOnlineDelegate OnFailure;
// Logs out of the identity interface // Gets the privilage of the user
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity")
static UGetUserPrivilegeCallbackProxy* GetUserPrivilege(UObject* WorldContextObject, const EBPUserPrivileges & PrivilegeToCheck, const FBPUniqueNetId & PlayerUniqueNetID); static UGetUserPrivilegeCallbackProxy* GetUserPrivilege(UObject* WorldContextObject, const EBPUserPrivileges & PrivilegeToCheck, const FBPUniqueNetId & PlayerUniqueNetID);
@@ -41,5 +41,5 @@ private:
EBPUserPrivileges UserPrivilege; EBPUserPrivileges UserPrivilege;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -3,7 +3,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "OnlineIdentityInterface.h" #include "Interfaces/OnlineIdentityInterface.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "LoginUserCallbackProxy.generated.h" #include "LoginUserCallbackProxy.generated.h"
@@ -20,9 +20,9 @@ class ULoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure; FEmptyOnlineDelegate OnFailure;
// Logs out of the identity interface // Logs into the identity interface
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject", AdvancedDisplay = "AuthType"), Category = "Online|AdvancedIdentity")
static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken); static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString AuthType);
// UOnlineBlueprintCallProxyBase interface // UOnlineBlueprintCallProxyBase interface
virtual void Activate() override; virtual void Activate() override;
@@ -42,6 +42,8 @@ private:
// The user pass / token // The user pass / token
FString UserToken; FString UserToken;
FString AuthType;
// The delegate executed by the online subsystem // The delegate executed by the online subsystem
FOnLoginCompleteDelegate Delegate; FOnLoginCompleteDelegate Delegate;
@@ -49,5 +51,5 @@ private:
FDelegateHandle DelegateHandle; FDelegateHandle DelegateHandle;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -3,7 +3,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "OnlineIdentityInterface.h" #include "Interfaces/OnlineIdentityInterface.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "LogoutUserCallbackProxy.generated.h" #include "LogoutUserCallbackProxy.generated.h"
@@ -43,5 +43,5 @@ private:
FDelegateHandle DelegateHandle; FDelegateHandle DelegateHandle;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -1,27 +1,27 @@
#pragma once #pragma once
//#include "EngineMinimal.h" //#include "EngineMinimal.h"
//#include "Core.h" //#include "Core.h"
//#include "OnlineSessionInterface.h" //#include "OnlineSessionInterface.h"
//#include "OnlineSessionSettings.h" //#include "OnlineSessionSettings.h"
//#include "OnlineDelegateMacros.h" //#include "OnlineDelegateMacros.h"
//#include "OnlineSubsystem.h" //#include "OnlineSubsystem.h"
//#include "OnlineSubsystemImpl.h" //#include "OnlineSubsystemImpl.h"
//#include "OnlineSubsystemUtils.h" //#include "OnlineSubsystemUtils.h"
//#include "OnlineSubsystemUtilsModule.h" //#include "OnlineSubsystemUtilsModule.h"
//#include "ModuleManager.h" //#include "ModuleManager.h"
//#include "OnlineSubsystemUtilsClasses.h" //#include "OnlineSubsystemUtilsClasses.h"
//#include "BlueprintDataDefinitions.h" //#include "BlueprintDataDefinitions.h"
/*#include "VoiceEngineImpl.h" /*#include "VoiceEngineImpl.h"
#include "VoiceInterfaceImpl.h" #include "VoiceInterfaceImpl.h"
#include "Voice.h"" #include "Voice.h""
*/ */
// Found this in the steam controller, seems like a nice thought since steam is throwing errors // Found this in the steam controller, seems like a nice thought since steam is throwing errors
// Disable crazy warnings that claim that standard C library is "deprecated". // Disable crazy warnings that claim that standard C library is "deprecated".
//#ifdef _MSC_VER //#ifdef _MSC_VER
//#pragma warning(push) //#pragma warning(push)
//#pragma warning(disable:4996) //#pragma warning(disable:4996)
//#endif //#endif

View File

@@ -1,49 +1,49 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "SendFriendInviteCallbackProxy.generated.h" #include "SendFriendInviteCallbackProxy.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSendFriendInviteLog, Log, All); DECLARE_LOG_CATEGORY_EXTERN(AdvancedSendFriendInviteLog, Log, All);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBlueprintSendFriendInviteDelegate); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FBlueprintSendFriendInviteDelegate);
UCLASS(MinimalAPI) UCLASS(MinimalAPI)
class USendFriendInviteCallbackProxy : public UOnlineBlueprintCallProxyBase class USendFriendInviteCallbackProxy : public UOnlineBlueprintCallProxyBase
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
// Called when the friends list successfully was retrieved // Called when the friends list successfully was retrieved
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintSendFriendInviteDelegate OnSuccess; FBlueprintSendFriendInviteDelegate OnSuccess;
// Called when there was an error retrieving the friends list // Called when there was an error retrieving the friends list
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintSendFriendInviteDelegate OnFailure; FBlueprintSendFriendInviteDelegate OnFailure;
// Adds a friend who is using the defined UniqueNetId, some interfaces do now allow this function to be called (INCLUDING STEAM) // Adds a friend who is using the defined UniqueNetId, some interfaces do now allow this function to be called (INCLUDING STEAM)
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedFriends")
static USendFriendInviteCallbackProxy* SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited); static USendFriendInviteCallbackProxy* SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited);
virtual void Activate() override; virtual void Activate() override;
private: private:
// Internal callback when the friends list is retrieved // Internal callback when the friends list is retrieved
void OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString); void OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString);
// The player controller triggering things // The player controller triggering things
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr; TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
// The UniqueNetID of the person to invite // The UniqueNetID of the person to invite
FBPUniqueNetId cUniqueNetId; FBPUniqueNetId cUniqueNetId;
// The delegate to call on completion // The delegate to call on completion
FOnSendInviteComplete OnSendInviteCompleteDelegate; FOnSendInviteComplete OnSendInviteCompleteDelegate;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -0,0 +1,46 @@
#pragma once
#include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h"
#include "StartSessionCallbackProxyAdvanced.generated.h"
UCLASS(MinimalAPI)
class UStartSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
{
GENERATED_UCLASS_BODY()
// Called when the session starts successfully
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnSuccess;
// Called when there is an error starting the session
UPROPERTY(BlueprintAssignable)
FEmptyOnlineDelegate OnFailure;
/**
* Starts a session with the default online subsystem. The session needs to be previously created by calling the "CreateAdvancedSession" node.
* @param WorldContextObject
*/
UFUNCTION(
BlueprintCallable
, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject")
, Category = "Online|AdvancedSessions"
)
static UStartSessionCallbackProxyAdvanced* StartAdvancedSession(UObject* WorldContextObject);
// UOnlineBlueprintCallProxyBase interface
virtual void Activate() override;
// End of UOnlineBlueprintCallProxyBase interface
private:
// Internal callback when session start completes
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
// The delegate executed by the online subsystem
FOnStartSessionCompleteDelegate StartCompleteDelegate;
// Handles to the registered delegates above
FDelegateHandle StartCompleteDelegateHandle;
// The world context object in which this call is taking place
TWeakObjectPtr<UObject> WorldContextObject;
};

View File

@@ -2,6 +2,7 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Engine/Engine.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "UpdateSessionCallbackProxyAdvanced.generated.h" #include "UpdateSessionCallbackProxyAdvanced.generated.h"
@@ -20,7 +21,7 @@ class UUpdateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
// Creates a session with the default online subsystem with advanced optional inputs, you MUST fill in all categories or it will pass in values that you didn't want as default values // Creates a session with the default online subsystem with advanced optional inputs, you MUST fill in all categories or it will pass in values that you didn't want as default values
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false); static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false, bool bShouldAdvertise = true);
// UOnlineBlueprintCallProxyBase interface // UOnlineBlueprintCallProxyBase interface
virtual void Activate() override; virtual void Activate() override;
@@ -37,30 +38,32 @@ private:
FDelegateHandle OnUpdateSessionCompleteDelegateHandle; FDelegateHandle OnUpdateSessionCompleteDelegateHandle;
// Number of public connections // Number of public connections
int NumPublicConnections; int NumPublicConnections = 100;
// Number of private connections // Number of private connections
int NumPrivateConnections; int NumPrivateConnections = 0;
// Whether or not to search LAN // Whether or not to search LAN
bool bUseLAN; bool bUseLAN = false;
// Whether or not to allow invites // Whether or not to allow invites
bool bAllowInvites; bool bAllowInvites = true;
// Store extra settings // Store extra settings
TArray<FSessionPropertyKeyPair> ExtraSettings; TArray<FSessionPropertyKeyPair> ExtraSettings;
// Whether to update the online data // Whether to update the online data
bool bRefreshOnlineData; bool bRefreshOnlineData = true;
// Allow joining in progress // Allow joining in progress
bool bAllowJoinInProgress; bool bAllowJoinInProgress = true;
// Update whether this is a dedicated server or not // Update whether this is a dedicated server or not
bool bDedicatedServer; bool bDedicatedServer = false;
bool bShouldAdvertise = true;
// The world context object in which this call is taking place // The world context object in which this call is taking place
UObject* WorldContextObject; TWeakObjectPtr<UObject> WorldContextObject;
}; };

View File

@@ -1,160 +1,209 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedExternalUILibrary.h" #include "AdvancedExternalUILibrary.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedExternalUILog); DEFINE_LOG_CATEGORY(AdvancedExternalUILog);
void UAdvancedExternalUILibrary::ShowAccountUpgradeUI(const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result) void UAdvancedExternalUILibrary::ShowAccountUpgradeUI(UObject* WorldContextObject, const FBPUniqueNetId PlayerRequestingAccountUpgradeUI, EBlueprintResultSwitch &Result)
{ {
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!ExternalUIInterface.IsValid()) if (!IsValid(World))
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowAccountUpgradeUI Failed to get External UI interface!")); Result = EBlueprintResultSwitch::OnFailure;
Result = EBlueprintResultSwitch::OnFailure; return;
return; }
}
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(World);
ExternalUIInterface->ShowAccountUpgradeUI(*PlayerRequestingAccountUpgradeUI.GetUniqueNetId());
Result = EBlueprintResultSwitch::OnSuccess; if (!ExternalUIInterface.IsValid())
} {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowAccountUpgradeUI Failed to get External UI interface!"));
void UAdvancedExternalUILibrary::ShowProfileUI(const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result) Result = EBlueprintResultSwitch::OnFailure;
{ return;
}
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface();
ExternalUIInterface->ShowAccountUpgradeUI(*PlayerRequestingAccountUpgradeUI.GetUniqueNetId());
if (!ExternalUIInterface.IsValid()) Result = EBlueprintResultSwitch::OnSuccess;
{ }
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowProfileUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; void UAdvancedExternalUILibrary::ShowProfileUI(UObject* WorldContextObject, const FBPUniqueNetId PlayerViewingProfile, const FBPUniqueNetId PlayerToViewProfileOf, EBlueprintResultSwitch &Result)
return; {
}
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
ExternalUIInterface->ShowProfileUI(*PlayerViewingProfile.GetUniqueNetId(), *PlayerToViewProfileOf.GetUniqueNetId(), NULL); if (!IsValid(World))
Result = EBlueprintResultSwitch::OnSuccess; {
} Result = EBlueprintResultSwitch::OnFailure;
return;
}
void UAdvancedExternalUILibrary::ShowWebURLUI(FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded, bool bShowBackground, bool bShowCloseButton, int32 OffsetX, int32 OffsetY, int32 SizeX, int32 SizeY) IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(World);
{
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); if (!ExternalUIInterface.IsValid())
{
if (!ExternalUIInterface.IsValid()) UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowProfileUI Failed to get External UI interface!"));
{ Result = EBlueprintResultSwitch::OnFailure;
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowWebURLUI Failed to get External UI interface!")); return;
Result = EBlueprintResultSwitch::OnFailure; }
return;
} ExternalUIInterface->ShowProfileUI(*PlayerViewingProfile.GetUniqueNetId(), *PlayerToViewProfileOf.GetUniqueNetId(), NULL);
Result = EBlueprintResultSwitch::OnSuccess;
URLToShow = URLToShow.Replace(TEXT("http://"), TEXT("")); }
URLToShow = URLToShow.Replace(TEXT("https://"), TEXT(""));
FShowWebUrlParams Params;
Params.AllowedDomains = AllowedDomains; void UAdvancedExternalUILibrary::ShowWebURLUI(UObject* WorldContextObject, FString URLToShow, EBlueprintResultSwitch &Result, TArray<FString>& AllowedDomains, bool bEmbedded, bool bShowBackground, bool bShowCloseButton, int32 OffsetX, int32 OffsetY, int32 SizeX, int32 SizeY)
Params.bEmbedded = bEmbedded; {
Params.bShowBackground = bShowBackground; UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
Params.bShowCloseButton = bShowCloseButton; if (!IsValid(World))
Params.OffsetX = OffsetX; {
Params.OffsetY = OffsetY; Result = EBlueprintResultSwitch::OnFailure;
Params.SizeX = SizeX; return;
Params.SizeY = SizeY; }
ExternalUIInterface->ShowWebURL(URLToShow, Params); IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(World);
Result = EBlueprintResultSwitch::OnSuccess;
} if (!ExternalUIInterface.IsValid())
{
void UAdvancedExternalUILibrary::CloseWebURLUI() UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowWebURLUI Failed to get External UI interface!"));
{ Result = EBlueprintResultSwitch::OnFailure;
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); return;
}
if (!ExternalUIInterface.IsValid())
{ URLToShow = URLToShow.Replace(TEXT("http://"), TEXT(""));
UE_LOG(AdvancedExternalUILog, Warning, TEXT("CloseWebURLUI Failed to get External UI interface!")); URLToShow = URLToShow.Replace(TEXT("https://"), TEXT(""));
return;
} FShowWebUrlParams Params;
Params.AllowedDomains = AllowedDomains;
ExternalUIInterface->CloseWebURL(); Params.bEmbedded = bEmbedded;
} Params.bShowBackground = bShowBackground;
Params.bShowCloseButton = bShowCloseButton;
void UAdvancedExternalUILibrary::ShowLeaderBoardUI(FString LeaderboardName, EBlueprintResultSwitch &Result) Params.OffsetX = OffsetX;
{ Params.OffsetY = OffsetY;
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); Params.SizeX = SizeX;
Params.SizeY = SizeY;
if (!ExternalUIInterface.IsValid())
{ ExternalUIInterface->ShowWebURL(URLToShow, Params);
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowLeaderboardsUI Failed to get External UI interface!")); Result = EBlueprintResultSwitch::OnSuccess;
Result = EBlueprintResultSwitch::OnFailure; }
return;
} void UAdvancedExternalUILibrary::CloseWebURLUI(UObject* WorldContextObject)
{
ExternalUIInterface->ShowLeaderboardUI(LeaderboardName); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
Result = EBlueprintResultSwitch::OnSuccess; if (!IsValid(World))
{
} return;
}
void UAdvancedExternalUILibrary::ShowInviteUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result) IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(World);
{
if (!PlayerController) if (!ExternalUIInterface.IsValid())
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Had a bad Player Controller!")); UE_LOG(AdvancedExternalUILog, Warning, TEXT("CloseWebURLUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure; return;
return; }
}
ExternalUIInterface->CloseWebURL();
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); }
if (!ExternalUIInterface.IsValid()) void UAdvancedExternalUILibrary::ShowLeaderBoardUI(UObject* WorldContextObject, FString LeaderboardName, EBlueprintResultSwitch &Result)
{ {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get External UI interface!")); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
Result = EBlueprintResultSwitch::OnFailure; if (!IsValid(World))
return; {
} Result = EBlueprintResultSwitch::OnFailure;
return;
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); }
if (!Player) IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(World);
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get ULocalPlayer for the given PlayerController!")); if (!ExternalUIInterface.IsValid())
Result = EBlueprintResultSwitch::OnFailure; {
return; UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowLeaderboardsUI Failed to get External UI interface!"));
} Result = EBlueprintResultSwitch::OnFailure;
return;
ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), GameSessionName); }
Result = EBlueprintResultSwitch::OnSuccess;
} ExternalUIInterface->ShowLeaderboardUI(LeaderboardName);
Result = EBlueprintResultSwitch::OnSuccess;
void UAdvancedExternalUILibrary::ShowFriendsUI(APlayerController *PlayerController, EBlueprintResultSwitch &Result)
{ }
if (!PlayerController)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Had a bad Player Controller!")); void UAdvancedExternalUILibrary::ShowInviteUI(UObject* WorldContextObject, APlayerController *PlayerController, EBlueprintResultSwitch &Result)
Result = EBlueprintResultSwitch::OnFailure; {
return; if (!PlayerController)
} {
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Had a bad Player Controller!"));
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(); Result = EBlueprintResultSwitch::OnFailure;
return;
if (!ExternalUIInterface.IsValid()) }
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get External UI interface!")); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
Result = EBlueprintResultSwitch::OnFailure; if (!IsValid(World))
return; {
} Result = EBlueprintResultSwitch::OnFailure;
return;
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); }
if (!Player) IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(World);
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get ULocalPlayer for the given PlayerController!")); if (!ExternalUIInterface.IsValid())
Result = EBlueprintResultSwitch::OnFailure; {
return; UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get External UI interface!"));
} Result = EBlueprintResultSwitch::OnFailure;
return;
ExternalUIInterface->ShowFriendsUI(Player->GetControllerId()); }
Result = EBlueprintResultSwitch::OnSuccess;
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowInviteUI Failed to get ULocalPlayer for the given PlayerController!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), NAME_GameSession);
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedExternalUILibrary::ShowFriendsUI(UObject* WorldContextObject, APlayerController *PlayerController, EBlueprintResultSwitch &Result)
{
if (!PlayerController)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
Result = EBlueprintResultSwitch::OnFailure;
return;
}
IOnlineExternalUIPtr ExternalUIInterface = Online::GetExternalUIInterface(World);
if (!ExternalUIInterface.IsValid())
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get External UI interface!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player)
{
UE_LOG(AdvancedExternalUILog, Warning, TEXT("ShowFriendsUI Failed to get ULocalPlayer for the given PlayerController!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
ExternalUIInterface->ShowFriendsUI(Player->GetControllerId());
Result = EBlueprintResultSwitch::OnSuccess;
} }

View File

@@ -1,332 +1,334 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsGameInstance.h" #include "AdvancedFriendsGameInstance.h"
#include "Kismet/GameplayStatics.h"
//General Log #include "GameFramework/PlayerController.h"
DEFINE_LOG_CATEGORY(AdvancedFriendsInterfaceLog);
//General Log
UAdvancedFriendsGameInstance::UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer) DEFINE_LOG_CATEGORY(AdvancedFriendsInterfaceLog);
: Super(ObjectInitializer)
, bCallFriendInterfaceEventsOnPlayerControllers(true) UAdvancedFriendsGameInstance::UAdvancedFriendsGameInstance(const FObjectInitializer& ObjectInitializer)
, bCallIdentityInterfaceEventsOnPlayerControllers(true) : Super(ObjectInitializer)
, bCallVoiceInterfaceEventsOnPlayerControllers(true) , bCallFriendInterfaceEventsOnPlayerControllers(true)
, bEnableTalkingStatusDelegate(true) , bCallIdentityInterfaceEventsOnPlayerControllers(true)
, SessionInviteReceivedDelegate(FOnSessionInviteReceivedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteReceivedMaster)) , bCallVoiceInterfaceEventsOnPlayerControllers(true)
, SessionInviteAcceptedDelegate(FOnSessionUserInviteAcceptedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteAcceptedMaster)) , bEnableTalkingStatusDelegate(true)
, PlayerTalkingStateChangedDelegate(FOnPlayerTalkingStateChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerTalkingStateChangedMaster)) , SessionInviteReceivedDelegate(FOnSessionInviteReceivedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteReceivedMaster))
, PlayerLoginChangedDelegate(FOnLoginChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginChangedMaster)) , SessionInviteAcceptedDelegate(FOnSessionUserInviteAcceptedDelegate::CreateUObject(this, &ThisClass::OnSessionInviteAcceptedMaster))
, PlayerLoginStatusChangedDelegate(FOnLoginStatusChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginStatusChangedMaster)) , PlayerTalkingStateChangedDelegate(FOnPlayerTalkingStateChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerTalkingStateChangedMaster))
{ , PlayerLoginChangedDelegate(FOnLoginChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginChangedMaster))
} , PlayerLoginStatusChangedDelegate(FOnLoginStatusChangedDelegate::CreateUObject(this, &ThisClass::OnPlayerLoginStatusChangedMaster))
{
void UAdvancedFriendsGameInstance::Shutdown() }
{
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); void UAdvancedFriendsGameInstance::Shutdown()
{
if (!SessionInterface.IsValid()) IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());
{
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsGameInstance Failed to get session system!")); if (!SessionInterface.IsValid())
//return; {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsGameInstance Failed to get session system!"));
else //return;
{ }
// Clear all of the delegate handles here else
SessionInterface->ClearOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegateHandle); {
SessionInterface->ClearOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegateHandle); // Clear all of the delegate handles here
} SessionInterface->ClearOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegateHandle);
SessionInterface->ClearOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegateHandle);
}
if (bEnableTalkingStatusDelegate)
{
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (bEnableTalkingStatusDelegate)
{
if (VoiceInterface.IsValid()) IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld());
{
VoiceInterface->ClearOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegateHandle); if (VoiceInterface.IsValid())
} {
else VoiceInterface->ClearOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegateHandle);
{ }
else
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!")); {
}
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); }
if (IdentityInterface.IsValid()) IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
{
IdentityInterface->ClearOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegateHandle); if (IdentityInterface.IsValid())
{
IdentityInterface->ClearOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegateHandle);
// I am just defaulting to player 1
IdentityInterface->ClearOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegateHandle);
} // I am just defaulting to player 1
IdentityInterface->ClearOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegateHandle);
}
Super::Shutdown();
}
Super::Shutdown();
void UAdvancedFriendsGameInstance::Init() }
{
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();//OnlineSub->GetSessionInterface(); void UAdvancedFriendsGameInstance::Init()
{
if (SessionInterface.IsValid()) IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());//OnlineSub->GetSessionInterface();
{
// Currently doesn't store a handle or assign a delegate to any local player beyond the first.....should handle? if (SessionInterface.IsValid())
// Thought about directly handling it but friends for multiple players probably isn't required {
// Iterating through the local player TArray only works if it has had players assigned to it, most of the online interfaces don't support // Currently doesn't store a handle or assign a delegate to any local player beyond the first.....should handle?
// Multiple logins either (IE: Steam) // Thought about directly handling it but friends for multiple players probably isn't required
SessionInviteAcceptedDelegateHandle = SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegate); // Iterating through the local player TArray only works if it has had players assigned to it, most of the online interfaces don't support
// Multiple logins either (IE: Steam)
SessionInviteReceivedDelegateHandle = SessionInterface->AddOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegate); SessionInviteAcceptedDelegateHandle = SessionInterface->AddOnSessionUserInviteAcceptedDelegate_Handle(SessionInviteAcceptedDelegate);
}
else SessionInviteReceivedDelegateHandle = SessionInterface->AddOnSessionInviteReceivedDelegate_Handle(SessionInviteReceivedDelegate);
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get session interface!")); else
//return; {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get session interface!"));
//return;
// Beginning work on the voice interface }
if (bEnableTalkingStatusDelegate)
{ // Beginning work on the voice interface
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (bEnableTalkingStatusDelegate)
{
if (VoiceInterface.IsValid()) IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld());
{
PlayerTalkingStateChangedDelegateHandle = VoiceInterface->AddOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegate); if (VoiceInterface.IsValid())
} {
else PlayerTalkingStateChangedDelegateHandle = VoiceInterface->AddOnPlayerTalkingStateChangedDelegate_Handle(PlayerTalkingStateChangedDelegate);
{ }
else
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!")); {
}
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get voice interface!"));
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); }
if (IdentityInterface.IsValid()) IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
{
PlayerLoginChangedDelegateHandle = IdentityInterface->AddOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegate); if (IdentityInterface.IsValid())
{
// Just defaulting to player 1 PlayerLoginChangedDelegateHandle = IdentityInterface->AddOnLoginChangedDelegate_Handle(PlayerLoginChangedDelegate);
PlayerLoginStatusChangedDelegateHandle = IdentityInterface->AddOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegate);
} // Just defaulting to player 1
else PlayerLoginStatusChangedDelegateHandle = IdentityInterface->AddOnLoginStatusChangedDelegate_Handle(0, PlayerLoginStatusChangedDelegate);
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get identity interface!")); else
} {
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get identity interface!"));
}
Super::Init();
}
Super::Init();
/*void UAdvancedFriendsGameInstance::PostLoad() }
{
Super::PostLoad(); /*void UAdvancedFriendsGameInstance::PostLoad()
}*/ {
Super::PostLoad();
}*/
// Removed because it never gets called by the online subsystems
/*void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session)
{ // Removed because it never gets called by the online subsystems
// Just call the blueprint event to let the user handle this /*void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId &InvitedPlayer, const FUniqueNetId &FriendInviting, const FOnlineSessionSearchResult& Session)
{
FBPUniqueNetId IP, FI; // Just call the blueprint event to let the user handle this
IP.SetUniqueNetId(&InvitedPlayer); FBPUniqueNetId IP, FI;
FI.SetUniqueNetId(&FriendInviting); IP.SetUniqueNetId(&InvitedPlayer);
FBlueprintSessionResult BPS; FI.SetUniqueNetId(&FriendInviting);
BPS.OnlineResult = Session;
OnSessionInviteReceived(IP,FI,BPS); FBlueprintSessionResult BPS;
BPS.OnlineResult = Session;
TArray<class APlayerState*>& PlayerArray = GetWorld()->GetGameState()->PlayerArray; OnSessionInviteReceived(IP,FI,BPS);
const TArray<class ULocalPlayer*>&ControllerArray = this->GetLocalPlayers();
TArray<class APlayerState*>& PlayerArray = GetWorld()->GetGameState()->PlayerArray;
for (int i = 0; i < ControllerArray.Num(); i++) const TArray<class ULocalPlayer*>&ControllerArray = this->GetLocalPlayers();
{
if (*PlayerArray[ControllerArray[i]->PlayerController->NetPlayerIndex]->UniqueId.GetUniqueNetId().Get() == InvitedPlayer) for (int i = 0; i < ControllerArray.Num(); i++)
{ {
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore if (*PlayerArray[ControllerArray[i]->PlayerController->NetPlayerIndex]->UniqueId.GetUniqueNetId().Get() == InvitedPlayer)
if (ControllerArray[i]->PlayerController->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) {
{ //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(ControllerArray[i]->PlayerController, FI, BPS); if (ControllerArray[i]->PlayerController->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
} {
break; IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(ControllerArray[i]->PlayerController, FI, BPS);
} }
} break;
}*/ }
}
void UAdvancedFriendsGameInstance::OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID) }*/
{
EBPLoginStatus OrigStatus = (EBPLoginStatus)PreviousStatus; void UAdvancedFriendsGameInstance::OnPlayerLoginStatusChangedMaster(int32 PlayerNum, ELoginStatus::Type PreviousStatus, ELoginStatus::Type NewStatus, const FUniqueNetId & NewPlayerUniqueNetID)
EBPLoginStatus CurrentStatus = (EBPLoginStatus)NewStatus; {
FBPUniqueNetId PlayerID; EBPLoginStatus OrigStatus = (EBPLoginStatus)PreviousStatus;
PlayerID.SetUniqueNetId(&NewPlayerUniqueNetID); EBPLoginStatus CurrentStatus = (EBPLoginStatus)NewStatus;
FBPUniqueNetId PlayerID;
OnPlayerLoginStatusChanged(PlayerNum, OrigStatus,CurrentStatus,PlayerID); PlayerID.SetUniqueNetId(&NewPlayerUniqueNetID);
OnPlayerLoginStatusChanged(PlayerNum, OrigStatus,CurrentStatus,PlayerID);
if (bCallIdentityInterfaceEventsOnPlayerControllers)
{
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum); if (bCallIdentityInterfaceEventsOnPlayerControllers)
{
if (Player != NULL) APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum);
{
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore if (Player != NULL)
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) {
{ //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
IAdvancedFriendsInterface::Execute_OnPlayerLoginStatusChanged(Player, OrigStatus, CurrentStatus, PlayerID); if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
} {
} IAdvancedFriendsInterface::Execute_OnPlayerLoginStatusChanged(Player, OrigStatus, CurrentStatus, PlayerID);
else }
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginStatusChangedMaster!")); else
} {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginStatusChangedMaster!"));
} }
}
void UAdvancedFriendsGameInstance::OnPlayerLoginChangedMaster(int32 PlayerNum) }
{
OnPlayerLoginChanged(PlayerNum); void UAdvancedFriendsGameInstance::OnPlayerLoginChangedMaster(int32 PlayerNum)
{
if (bCallIdentityInterfaceEventsOnPlayerControllers) OnPlayerLoginChanged(PlayerNum);
{
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum); if (bCallIdentityInterfaceEventsOnPlayerControllers)
{
if (Player != NULL) APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), PlayerNum);
{
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore if (Player != NULL)
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) {
{ //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
IAdvancedFriendsInterface::Execute_OnPlayerLoginChanged(Player, PlayerNum); if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
} {
} IAdvancedFriendsInterface::Execute_OnPlayerLoginChanged(Player, PlayerNum);
else }
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginChanged!")); else
} {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnPlayerLoginChanged!"));
} }
}
void UAdvancedFriendsGameInstance::OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking) }
{
FBPUniqueNetId PlayerTalking; void UAdvancedFriendsGameInstance::OnPlayerTalkingStateChangedMaster(TSharedRef<const FUniqueNetId> PlayerId, bool bIsTalking)
PlayerTalking.SetUniqueNetId(PlayerId); {
OnPlayerTalkingStateChanged(PlayerTalking, bIsTalking); FBPUniqueNetId PlayerTalking;
PlayerTalking.SetUniqueNetId(PlayerId);
if (bCallVoiceInterfaceEventsOnPlayerControllers) OnPlayerTalkingStateChanged(PlayerTalking, bIsTalking);
{
APlayerController* Player = NULL; if (bCallVoiceInterfaceEventsOnPlayerControllers)
{
for (const ULocalPlayer* LPlayer : LocalPlayers) APlayerController* Player = NULL;
{
Player = UGameplayStatics::GetPlayerController(GetWorld(), LPlayer->GetControllerId()); for (const ULocalPlayer* LPlayer : LocalPlayers)
{
if (Player != NULL) Player = UGameplayStatics::GetPlayerController(GetWorld(), LPlayer->GetControllerId());
{
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore if (Player != NULL)
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) {
{ //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
IAdvancedFriendsInterface::Execute_OnPlayerVoiceStateChanged(Player, PlayerTalking, bIsTalking); if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
} {
} IAdvancedFriendsInterface::Execute_OnPlayerVoiceStateChanged(Player, PlayerTalking, bIsTalking);
else }
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnVoiceStateChanged!")); else
} {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnVoiceStateChanged!"));
} }
} }
}
void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString& AppId, const FOnlineSessionSearchResult& SessionToJoin) }
{
if (SessionToJoin.IsValid()) void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNetId & PersonInvited, const FUniqueNetId & PersonInviting, const FString& AppId, const FOnlineSessionSearchResult& SessionToJoin)
{ {
FBlueprintSessionResult BluePrintResult; if (SessionToJoin.IsValid())
BluePrintResult.OnlineResult = SessionToJoin; {
FBlueprintSessionResult BluePrintResult;
FBPUniqueNetId PInvited; BluePrintResult.OnlineResult = SessionToJoin;
PInvited.SetUniqueNetId(&PersonInvited);
FBPUniqueNetId PInvited;
FBPUniqueNetId PInviting; PInvited.SetUniqueNetId(&PersonInvited);
PInviting.SetUniqueNetId(&PersonInviting);
FBPUniqueNetId PInviting;
PInviting.SetUniqueNetId(&PersonInviting);
TArray<APlayerController*> PlayerList;
GEngine->GetAllLocalPlayerControllers(PlayerList);
TArray<APlayerController*> PlayerList;
APlayerController* Player = NULL; GEngine->GetAllLocalPlayerControllers(PlayerList);
int32 LocalPlayer = 0; APlayerController* Player = NULL;
for (int i = 0; i < PlayerList.Num(); i++)
{ int32 LocalPlayer = 0;
if (*PlayerList[i]->PlayerState->UniqueId.GetUniqueNetId() == PersonInvited) for (int i = 0; i < PlayerList.Num(); i++)
{ {
LocalPlayer = i; if (*PlayerList[i]->PlayerState->GetUniqueId().GetUniqueNetId() == PersonInvited)
Player = PlayerList[i]; {
break; LocalPlayer = i;
} Player = PlayerList[i];
} break;
}
OnSessionInviteReceived(LocalPlayer, PInviting, AppId, BluePrintResult); }
//IAdvancedFriendsInterface* TheInterface = NULL; OnSessionInviteReceived(LocalPlayer, PInviting, AppId, BluePrintResult);
if (Player != NULL) //IAdvancedFriendsInterface* TheInterface = NULL;
{
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore if (Player != NULL)
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) {
{ //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(Player, PInviting, BluePrintResult); if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
} {
} IAdvancedFriendsInterface::Execute_OnSessionInviteReceived(Player, PInviting, BluePrintResult);
else }
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteReceived!")); else
} {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteReceived!"));
else }
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteReceived!")); else
} {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteReceived!"));
}
void UAdvancedFriendsGameInstance::OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInvited, const FOnlineSessionSearchResult& SessionToJoin) }
{
if (bWasSuccessful) void UAdvancedFriendsGameInstance::OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInvited, const FOnlineSessionSearchResult& SessionToJoin)
{ {
if (SessionToJoin.IsValid()) if (bWasSuccessful)
{ {
if (SessionToJoin.IsValid())
FBlueprintSessionResult BluePrintResult; {
BluePrintResult.OnlineResult = SessionToJoin;
FBlueprintSessionResult BluePrintResult;
FBPUniqueNetId PInvited; BluePrintResult.OnlineResult = SessionToJoin;
PInvited.SetUniqueNetId(PersonInvited);
FBPUniqueNetId PInvited;
OnSessionInviteAccepted(LocalPlayer,PInvited, BluePrintResult); PInvited.SetUniqueNetId(PersonInvited);
APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), LocalPlayer); OnSessionInviteAccepted(LocalPlayer,PInvited, BluePrintResult);
//IAdvancedFriendsInterface* TheInterface = NULL; APlayerController* Player = UGameplayStatics::GetPlayerController(GetWorld(), LocalPlayer);
if (Player != NULL) //IAdvancedFriendsInterface* TheInterface = NULL;
{
//Run the Event specific to the actor, if the actor has the interface, otherwise ignore if (Player != NULL)
if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass())) {
{ //Run the Event specific to the actor, if the actor has the interface, otherwise ignore
IAdvancedFriendsInterface::Execute_OnSessionInviteAccepted(Player,PInvited, BluePrintResult); if (Player->GetClass()->ImplementsInterface(UAdvancedFriendsInterface::StaticClass()))
} {
} IAdvancedFriendsInterface::Execute_OnSessionInviteAccepted(Player,PInvited, BluePrintResult);
else }
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteAccepted!")); else
} {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Failed to get a controller with the specified index in OnSessionInviteAccepted!"));
else }
{ }
UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteAccepted!")); else
} {
} UE_LOG(AdvancedFriendsInterfaceLog, Warning, TEXT("UAdvancedFriendsInstance Return a bad search result in OnSessionInviteAccepted!"));
}
}
} }

View File

@@ -1,9 +1,9 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsInterface.h" #include "AdvancedFriendsInterface.h"
UAdvancedFriendsInterface::UAdvancedFriendsInterface(const class FObjectInitializer& ObjectInitializer) UAdvancedFriendsInterface::UAdvancedFriendsInterface(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
{ {
} }

View File

@@ -1,274 +1,274 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedFriendsLibrary.h" #include "AdvancedFriendsLibrary.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedFriendsLog); DEFINE_LOG_CATEGORY(AdvancedFriendsLog);
void UAdvancedFriendsLibrary::SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result) void UAdvancedFriendsLibrary::SendSessionInviteToFriends(APlayerController *PlayerController, const TArray<FBPUniqueNetId> &Friends, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (Friends.Num() < 1) if (Friends.Num() < 1)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had no friends in invitation array!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had no friends in invitation array!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
TArray<TSharedRef<const FUniqueNetId>> List; TArray<TSharedRef<const FUniqueNetId>> List;
for (int i = 0; i < Friends.Num(); i++) for (int i = 0; i < Friends.Num(); i++)
{ {
TSharedRef<const FUniqueNetId> val(Friends[i].UniqueNetId.ToSharedRef()); TSharedRef<const FUniqueNetId> val(Friends[i].UniqueNetId.ToSharedRef());
//TSharedRef<const FUniqueNetId> val(Friends[i].GetUniqueNetId()); //TSharedRef<const FUniqueNetId> val(Friends[i].GetUniqueNetId());
List.Add(val); List.Add(val);
} }
if (SessionInterface->SendSessionInviteToFriends(Player->GetControllerId(), GameSessionName, List)) if (SessionInterface->SendSessionInviteToFriends(Player->GetControllerId(), NAME_GameSession, List))
{ {
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
return; return;
} }
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
void UAdvancedFriendsLibrary::SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result) void UAdvancedFriendsLibrary::SendSessionInviteToFriend(APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad Player Controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (!FriendUniqueNetId.IsValid()) if (!FriendUniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Had a bad UniqueNetId!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend Failed to get session interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("SendSessionInviteToFriend failed to get LocalPlayer!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
if (SessionInterface->SendSessionInviteToFriend(Player->GetControllerId(), GameSessionName, *FriendUniqueNetId.GetUniqueNetId())) if (SessionInterface->SendSessionInviteToFriend(Player->GetControllerId(), NAME_GameSession, *FriendUniqueNetId.GetUniqueNetId()))
{ {
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
return; return;
} }
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
void UAdvancedFriendsLibrary::GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend) void UAdvancedFriendsLibrary::GetFriend(APlayerController *PlayerController, const FBPUniqueNetId FriendUniqueNetId, FBPFriendInfo &Friend)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad Player Controller!"));
return; return;
} }
if (!FriendUniqueNetId.IsValid()) if (!FriendUniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Had a bad UniqueNetId!"));
return; return;
} }
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend Failed to get friends interface!"));
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriend failed to get LocalPlayer!"));
return; return;
} }
TSharedPtr<FOnlineFriend> fr = FriendsInterface->GetFriend(Player->GetControllerId(), *FriendUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default)); TSharedPtr<FOnlineFriend> fr = FriendsInterface->GetFriend(Player->GetControllerId(), *FriendUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default));
if (fr.IsValid()) if (fr.IsValid())
{ {
FOnlineUserPresence pres = fr->GetPresence(); FOnlineUserPresence pres = fr->GetPresence();
Friend.DisplayName = fr->GetDisplayName(); Friend.DisplayName = fr->GetDisplayName();
Friend.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); Friend.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
Friend.RealName = fr->GetRealName(); Friend.RealName = fr->GetRealName();
Friend.UniqueNetId.SetUniqueNetId(fr->GetUserId()); Friend.UniqueNetId.SetUniqueNetId(fr->GetUserId());
Friend.bIsPlayingSameGame = pres.bIsPlayingThisGame; Friend.bIsPlayingSameGame = pres.bIsPlayingThisGame;
Friend.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; Friend.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
Friend.PresenceInfo.bIsJoinable = pres.bIsJoinable; Friend.PresenceInfo.bIsJoinable = pres.bIsJoinable;
Friend.PresenceInfo.bIsOnline = pres.bIsOnline; Friend.PresenceInfo.bIsOnline = pres.bIsOnline;
Friend.PresenceInfo.bIsPlaying = pres.bIsPlaying; Friend.PresenceInfo.bIsPlaying = pres.bIsPlaying;
Friend.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; Friend.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
Friend.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); Friend.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
Friend.PresenceInfo.StatusString = pres.Status.StatusStr; Friend.PresenceInfo.StatusString = pres.Status.StatusStr;
} }
} }
void UAdvancedFriendsLibrary::IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend) void UAdvancedFriendsLibrary::IsAFriend(APlayerController *PlayerController, const FBPUniqueNetId UniqueNetId, bool &IsFriend)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad Player Controller!"));
return; return;
} }
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
return; return;
} }
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get friends interface!"));
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("IsAFriend Failed to get LocalPlayer!"));
return; return;
} }
IsFriend = FriendsInterface->IsFriend(Player->GetControllerId(), *UniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default)); IsFriend = FriendsInterface->IsFriend(Player->GetControllerId(), *UniqueNetId.GetUniqueNetId(), EFriendsLists::ToString(EFriendsLists::Default));
} }
void UAdvancedFriendsLibrary::GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList) void UAdvancedFriendsLibrary::GetStoredRecentPlayersList(FBPUniqueNetId UniqueNetId, TArray<FBPOnlineRecentPlayer> &PlayersList)
{ {
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed to get friends interface!"));
return; return;
} }
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed was given an invalid UniqueNetId!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetRecentPlayersList Failed was given an invalid UniqueNetId!"));
return; return;
} }
TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList; TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList;
// For now getting all namespaces // For now getting all namespaces
FriendsInterface->GetRecentPlayers(*(UniqueNetId.GetUniqueNetId()),"", PlayerList); FriendsInterface->GetRecentPlayers(*(UniqueNetId.GetUniqueNetId()),"", PlayerList);
for (int32 i = 0; i < PlayerList.Num(); i++) for (int32 i = 0; i < PlayerList.Num(); i++)
{ {
TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i]; TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i];
FBPOnlineRecentPlayer BPF; FBPOnlineRecentPlayer BPF;
BPF.DisplayName = Player->GetDisplayName(); BPF.DisplayName = Player->GetDisplayName();
BPF.RealName = Player->GetRealName(); BPF.RealName = Player->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId()); BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId());
PlayersList.Add(BPF); PlayersList.Add(BPF);
} }
} }
void UAdvancedFriendsLibrary::GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList) void UAdvancedFriendsLibrary::GetStoredFriendsList(APlayerController *PlayerController, TArray<FBPFriendInfo> &FriendsList)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Had a bad Player Controller!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Had a bad Player Controller!"));
return; return;
} }
IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface(); IOnlineFriendsPtr FriendsInterface = Online::GetFriendsInterface();
if (!FriendsInterface.IsValid()) if (!FriendsInterface.IsValid())
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get friends interface!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get friends interface!"));
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get LocalPlayer!")); UE_LOG(AdvancedFriendsLog, Warning, TEXT("GetFriendsList Failed to get LocalPlayer!"));
return; return;
} }
TArray< TSharedRef<FOnlineFriend> > FriendList; TArray< TSharedRef<FOnlineFriend> > FriendList;
FriendsInterface->GetFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendList); FriendsInterface->GetFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendList);
for (int32 i = 0; i < FriendList.Num(); i++) for (int32 i = 0; i < FriendList.Num(); i++)
{ {
TSharedRef<FOnlineFriend> Friend = FriendList[i]; TSharedRef<FOnlineFriend> Friend = FriendList[i];
FBPFriendInfo BPF; FBPFriendInfo BPF;
FOnlineUserPresence pres = Friend->GetPresence(); FOnlineUserPresence pres = Friend->GetPresence();
BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
BPF.DisplayName = Friend->GetDisplayName(); BPF.DisplayName = Friend->GetDisplayName();
BPF.RealName = Friend->GetRealName(); BPF.RealName = Friend->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId()); BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame;
BPF.PresenceInfo.bIsOnline = pres.bIsOnline; BPF.PresenceInfo.bIsOnline = pres.bIsOnline;
BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying; BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
BPF.PresenceInfo.StatusString = pres.Status.StatusStr; BPF.PresenceInfo.StatusString = pres.Status.StatusStr;
BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable;
BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame; BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
FriendsList.Add(BPF); FriendsList.Add(BPF);
} }
} }

View File

@@ -1,235 +1,271 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedIdentityLibrary.h" #include "AdvancedIdentityLibrary.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedIdentityLog); DEFINE_LOG_CATEGORY(AdvancedIdentityLog);
void UAdvancedIdentityLibrary::GetPlayerAuthToken(APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetPlayerAuthToken(UObject* WorldContextObject, APlayerController * PlayerController, FString & AuthToken, EBlueprintResultSwitch &Result)
{ {
if (!PlayerController) if (!PlayerController)
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken was passed a bad player controller!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken was passed a bad player controller!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerController->Player);
if (!Player) if (!Player)
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken failed to get LocalPlayer!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken failed to get LocalPlayer!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
if (!IdentityInterface.IsValid()) {
{ Result = EBlueprintResultSwitch::OnFailure;
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken Failed to get identity interface!")); return;
Result = EBlueprintResultSwitch::OnFailure; }
return;
} IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(World);
AuthToken = IdentityInterface->GetAuthToken(Player->GetControllerId()); if (!IdentityInterface.IsValid())
Result = EBlueprintResultSwitch::OnSuccess; {
} UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerAuthToken Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure;
void UAdvancedIdentityLibrary::GetPlayerNickname(const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname) return;
{ }
if (!UniqueNetID.IsValid())
{ AuthToken = IdentityInterface->GetAuthToken(Player->GetControllerId());
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname was passed a bad player uniquenetid!")); Result = EBlueprintResultSwitch::OnSuccess;
return; }
}
void UAdvancedIdentityLibrary::GetPlayerNickname(UObject* WorldContextObject, const FBPUniqueNetId & UniqueNetID, FString & PlayerNickname)
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); {
if (!UniqueNetID.IsValid())
if (!IdentityInterface.IsValid()) {
{ UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname was passed a bad player uniquenetid!"));
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname Failed to get identity interface!")); return;
return; }
}
PlayerNickname = IdentityInterface->GetPlayerNickname(*UniqueNetID.GetUniqueNetId()); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
} if (!IsValid(World))
{
return;
void UAdvancedIdentityLibrary::GetLoginStatus(const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result) }
{
if (!UniqueNetID.IsValid()) IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(World);
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus was passed a bad player uniquenetid!")); if (!IdentityInterface.IsValid())
Result = EBlueprintResultSwitch::OnFailure; {
return; UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetPlayerNickname Failed to get identity interface!"));
} return;
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); PlayerNickname = IdentityInterface->GetPlayerNickname(*UniqueNetID.GetUniqueNetId());
}
if (!IdentityInterface.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus Failed to get identity interface!")); void UAdvancedIdentityLibrary::GetLoginStatus(UObject* WorldContextObject, const FBPUniqueNetId & UniqueNetID, EBPLoginStatus & LoginStatus, EBlueprintResultSwitch &Result)
Result = EBlueprintResultSwitch::OnFailure; {
return; if (!UniqueNetID.IsValid())
} {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus was passed a bad player uniquenetid!"));
LoginStatus = (EBPLoginStatus)IdentityInterface->GetLoginStatus(*UniqueNetID.GetUniqueNetId()); Result = EBlueprintResultSwitch::OnFailure;
Result = EBlueprintResultSwitch::OnSuccess; return;
} }
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
void UAdvancedIdentityLibrary::GetAllUserAccounts(TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result) if (!IsValid(World))
{ {
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); Result = EBlueprintResultSwitch::OnFailure;
return;
if (!IdentityInterface.IsValid()) }
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetAllUserAccounts Failed to get identity interface!")); IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(World);
Result = EBlueprintResultSwitch::OnFailure;
return; if (!IdentityInterface.IsValid())
} {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetLoginStatus Failed to get identity interface!"));
TArray<TSharedPtr<FUserOnlineAccount>> accountInfos = IdentityInterface->GetAllUserAccounts(); Result = EBlueprintResultSwitch::OnFailure;
return;
for (int i = 0; i < accountInfos.Num(); ++i) }
{
AccountInfos.Add(FBPUserOnlineAccount(accountInfos[i])); LoginStatus = (EBPLoginStatus)IdentityInterface->GetLoginStatus(*UniqueNetID.GetUniqueNetId());
} Result = EBlueprintResultSwitch::OnSuccess;
}
Result = EBlueprintResultSwitch::OnSuccess;
}
void UAdvancedIdentityLibrary::GetAllUserAccounts(UObject* WorldContextObject, TArray<FBPUserOnlineAccount> & AccountInfos, EBlueprintResultSwitch &Result)
void UAdvancedIdentityLibrary::GetUserAccount(const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result) {
{
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
if(!UniqueNetId.IsValid()) {
{ Result = EBlueprintResultSwitch::OnFailure;
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount was passed a bad unique net id!")); return;
Result = EBlueprintResultSwitch::OnFailure; }
return;
} IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(World);
if (!IdentityInterface.IsValid()) if (!IdentityInterface.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get identity interface!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetAllUserAccounts Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnFailure;
return; return;
} }
TSharedPtr<FUserOnlineAccount> accountInfo = IdentityInterface->GetUserAccount(*UniqueNetId.GetUniqueNetId()); TArray<TSharedPtr<FUserOnlineAccount>> accountInfos = IdentityInterface->GetAllUserAccounts();
if (!accountInfo.IsValid()) for (int i = 0; i < accountInfos.Num(); ++i)
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get the account!")); AccountInfos.Add(FBPUserOnlineAccount(accountInfos[i]));
Result = EBlueprintResultSwitch::OnFailure; }
return;
} Result = EBlueprintResultSwitch::OnSuccess;
}
AccountInfo.UserAccountInfo = accountInfo;
Result = EBlueprintResultSwitch::OnSuccess; void UAdvancedIdentityLibrary::GetUserAccount(UObject* WorldContextObject, const FBPUniqueNetId & UniqueNetId, FBPUserOnlineAccount & AccountInfo, EBlueprintResultSwitch &Result)
} {
void UAdvancedIdentityLibrary::GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken) UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
{ if (!IsValid(World))
if (!AccountInfo.UserAccountInfo.IsValid()) {
{ Result = EBlueprintResultSwitch::OnFailure;
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAccessToken was passed an invalid account!")); return;
return; }
}
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(World);
AccessToken = AccountInfo.UserAccountInfo->GetAccessToken();
} if(!UniqueNetId.IsValid())
{
void UAdvancedIdentityLibrary::GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result) UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount was passed a bad unique net id!"));
{ Result = EBlueprintResultSwitch::OnFailure;
if (!AccountInfo.UserAccountInfo.IsValid()) return;
{ }
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure; if (!IdentityInterface.IsValid())
return; {
} UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get identity interface!"));
Result = EBlueprintResultSwitch::OnFailure;
if (!AccountInfo.UserAccountInfo->GetAuthAttribute(AttributeName, AuthAttribute)) return;
{ }
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute couldn't find the attribute!"));
Result = EBlueprintResultSwitch::OnFailure; TSharedPtr<FUserOnlineAccount> accountInfo = IdentityInterface->GetUserAccount(*UniqueNetId.GetUniqueNetId());
return;
} if (!accountInfo.IsValid())
{
Result = EBlueprintResultSwitch::OnSuccess; UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccount Failed to get the account!"));
} Result = EBlueprintResultSwitch::OnFailure;
return;
void UAdvancedIdentityLibrary::SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result) }
{
if (!AccountInfo.UserAccountInfo.IsValid()) AccountInfo.UserAccountInfo = accountInfo;
{ Result = EBlueprintResultSwitch::OnSuccess;
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was passed an invalid account!")); }
Result = EBlueprintResultSwitch::OnFailure;
return; void UAdvancedIdentityLibrary::GetUserAccountAccessToken(const FBPUserOnlineAccount & AccountInfo, FString & AccessToken)
} {
if (!AccountInfo.UserAccountInfo.IsValid())
if (!AccountInfo.UserAccountInfo->SetUserAttribute(AttributeName, NewAttributeValue)) {
{ UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAccessToken was passed an invalid account!"));
UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was unable to set the attribute!")); return;
Result = EBlueprintResultSwitch::OnFailure; }
return;
} AccessToken = AccountInfo.UserAccountInfo->GetAccessToken();
}
Result = EBlueprintResultSwitch::OnSuccess;
} void UAdvancedIdentityLibrary::GetUserAccountAuthAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AuthAttribute, EBlueprintResultSwitch &Result)
{
void UAdvancedIdentityLibrary::GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute was passed an invalid account!"));
{ Result = EBlueprintResultSwitch::OnFailure;
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserID was passed an invalid account!")); return;
return; }
}
if (!AccountInfo.UserAccountInfo->GetAuthAttribute(AttributeName, AuthAttribute))
{
UniqueNetID.SetUniqueNetId(AccountInfo.UserAccountInfo->GetUserId()); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAuthAttribute couldn't find the attribute!"));
} Result = EBlueprintResultSwitch::OnFailure;
return;
void UAdvancedIdentityLibrary::GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName) }
{
if (!AccountInfo.UserAccountInfo.IsValid()) Result = EBlueprintResultSwitch::OnSuccess;
{ }
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountRealName was passed an invalid account!"));
return; void UAdvancedIdentityLibrary::SetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, const FString & NewAttributeValue, EBlueprintResultSwitch &Result)
} {
if (!AccountInfo.UserAccountInfo.IsValid())
{
UserName = AccountInfo.UserAccountInfo->GetRealName(); UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was passed an invalid account!"));
} Result = EBlueprintResultSwitch::OnFailure;
return;
void UAdvancedIdentityLibrary::GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName) }
{
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo->SetUserAttribute(AttributeName, NewAttributeValue))
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountDisplayName was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("SetUserAccountAuthAttribute was unable to set the attribute!"));
return; Result = EBlueprintResultSwitch::OnFailure;
} return;
}
DisplayName = AccountInfo.UserAccountInfo->GetDisplayName(); Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedIdentityLibrary::GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result) void UAdvancedIdentityLibrary::GetUserID(const FBPUserOnlineAccount & AccountInfo, FBPUniqueNetId & UniqueNetID)
{ {
if (!AccountInfo.UserAccountInfo.IsValid()) if (!AccountInfo.UserAccountInfo.IsValid())
{ {
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute was passed an invalid account!")); UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserID was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure; return;
return; }
}
if (!AccountInfo.UserAccountInfo->GetUserAttribute(AttributeName, AttributeValue)) UniqueNetID.SetUniqueNetId(AccountInfo.UserAccountInfo->GetUserId());
{ }
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute failed to get user attribute!"));
Result = EBlueprintResultSwitch::OnFailure; void UAdvancedIdentityLibrary::GetUserAccountRealName(const FBPUserOnlineAccount & AccountInfo, FString & UserName)
return; {
} if (!AccountInfo.UserAccountInfo.IsValid())
{
Result = EBlueprintResultSwitch::OnSuccess; UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountRealName was passed an invalid account!"));
return;
}
UserName = AccountInfo.UserAccountInfo->GetRealName();
}
void UAdvancedIdentityLibrary::GetUserAccountDisplayName(const FBPUserOnlineAccount & AccountInfo, FString & DisplayName)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountDisplayName was passed an invalid account!"));
return;
}
DisplayName = AccountInfo.UserAccountInfo->GetDisplayName();
}
void UAdvancedIdentityLibrary::GetUserAccountAttribute(const FBPUserOnlineAccount & AccountInfo, const FString & AttributeName, FString & AttributeValue, EBlueprintResultSwitch &Result)
{
if (!AccountInfo.UserAccountInfo.IsValid())
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute was passed an invalid account!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
if (!AccountInfo.UserAccountInfo->GetUserAttribute(AttributeName, AttributeValue))
{
UE_LOG(AdvancedIdentityLog, Warning, TEXT("GetUserAccountAttribute failed to get user attribute!"));
Result = EBlueprintResultSwitch::OnFailure;
return;
}
Result = EBlueprintResultSwitch::OnSuccess;
} }

View File

@@ -1,12 +1,12 @@
//#include "StandAlonePrivatePCH.h" //#include "StandAlonePrivatePCH.h"
#include "AdvancedSessions.h" #include "AdvancedSessions.h"
void AdvancedSessions::StartupModule() void AdvancedSessions::StartupModule()
{ {
} }
void AdvancedSessions::ShutdownModule() void AdvancedSessions::ShutdownModule()
{ {
} }
IMPLEMENT_MODULE(AdvancedSessions, AdvancedSessions) IMPLEMENT_MODULE(AdvancedSessions, AdvancedSessions)

View File

@@ -1,17 +1,93 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedSessionsLibrary.h" #include "AdvancedSessionsLibrary.h"
#include "GameFramework/PlayerState.h" #include "GameFramework/PlayerState.h"
#include "GameFramework/GameStateBase.h" #include "GameFramework/GameStateBase.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedSessionsLog); DEFINE_LOG_CATEGORY(AdvancedSessionsLog);
bool UAdvancedSessionsLibrary::KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason)
{
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (World)
{
if (AGameModeBase* GameMode = World->GetAuthGameMode())
{
if (GameMode->GameSession)
{
return GameMode->GameSession->KickPlayer(PlayerToKick, KickReason);
}
}
}
return false;
}
bool UAdvancedSessionsLibrary::BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason)
{
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (World)
{
if (AGameModeBase* GameMode = World->GetAuthGameMode())
{
if (GameMode->GameSession)
{
return GameMode->GameSession->BanPlayer(PlayerToBan, BanReason);
}
}
}
return false;
}
bool UAdvancedSessionsLibrary::IsValidSession(const FBlueprintSessionResult & SessionResult) bool UAdvancedSessionsLibrary::IsValidSession(const FBlueprintSessionResult & SessionResult)
{ {
return SessionResult.OnlineResult.IsValid(); return SessionResult.OnlineResult.IsValid();
} }
void UAdvancedSessionsLibrary::GetSessionID_AsString(const FBlueprintSessionResult & SessionResult, FString& SessionID)
{
const TSharedPtr<class FOnlineSessionInfo> SessionInfo = SessionResult.OnlineResult.Session.SessionInfo;
if (SessionInfo.IsValid() && SessionInfo->IsValid() && SessionInfo->GetSessionId().IsValid())
{
SessionID = SessionInfo->GetSessionId().ToString();
return;
}
// Zero the string out if we didn't have a valid one, in case this is called in c++
SessionID.Empty();
}
void UAdvancedSessionsLibrary::GetCurrentSessionID_AsString(UObject* WorldContextObject, FString& SessionID)
{
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
if (!SessionInterface.IsValid())
{
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetCurrentSessionID_AsString couldn't get the session interface!"));
SessionID.Empty();
return;
}
const FNamedOnlineSession* Session = SessionInterface->GetNamedSession(NAME_GameSession);
if (Session != nullptr)
{
const TSharedPtr<class FOnlineSessionInfo> SessionInfo = Session->SessionInfo;
if (SessionInfo.IsValid() && SessionInfo->IsValid() && SessionInfo->GetSessionId().IsValid())
{
SessionID = SessionInfo->GetSessionId().ToString();
return;
}
}
// Zero the string out if we didn't have a valid one, in case this is called in c++
SessionID.Empty();
}
void UAdvancedSessionsLibrary::GetCurrentUniqueBuildID(int32 &UniqueBuildId) void UAdvancedSessionsLibrary::GetCurrentUniqueBuildID(int32 &UniqueBuildId)
{ {
UniqueBuildId = GetBuildUniqueId(); UniqueBuildId = GetBuildUniqueId();
@@ -22,6 +98,31 @@ void UAdvancedSessionsLibrary::GetUniqueBuildID(FBlueprintSessionResult SessionR
UniqueBuildId = SessionResult.OnlineResult.Session.SessionSettings.BuildUniqueId; UniqueBuildId = SessionResult.OnlineResult.Session.SessionSettings.BuildUniqueId;
} }
FName UAdvancedSessionsLibrary::GetSessionPropertyKey(const FSessionPropertyKeyPair& SessionProperty)
{
return SessionProperty.Key;
}
void UAdvancedSessionsLibrary::FindSessionPropertyByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingName, EBlueprintResultSwitch &Result, FSessionPropertyKeyPair& OutProperty)
{
const FSessionPropertyKeyPair* prop = ExtraSettings.FindByPredicate([&](const FSessionPropertyKeyPair& it) {return it.Key == SettingName; });
if (prop)
{
Result = EBlueprintResultSwitch::OnSuccess;
OutProperty = *prop;
return;
}
Result = EBlueprintResultSwitch::OnFailure;
}
void UAdvancedSessionsLibrary::FindSessionPropertyIndexByName(const TArray<FSessionPropertyKeyPair>& ExtraSettings, FName SettingName, EBlueprintResultSwitch &Result, int32& OutIndex)
{
OutIndex = ExtraSettings.IndexOfByPredicate([&](const FSessionPropertyKeyPair& it) {return it.Key == SettingName; });
Result = OutIndex != INDEX_NONE ? EBlueprintResultSwitch::OnSuccess : EBlueprintResultSwitch::OnFailure;
}
void UAdvancedSessionsLibrary::AddOrModifyExtraSettings(UPARAM(ref) TArray<FSessionPropertyKeyPair> & SettingsArray, UPARAM(ref) TArray<FSessionPropertyKeyPair> & NewOrChangedSettings, TArray<FSessionPropertyKeyPair> & ModifiedSettingsArray) void UAdvancedSessionsLibrary::AddOrModifyExtraSettings(UPARAM(ref) TArray<FSessionPropertyKeyPair> & SettingsArray, UPARAM(ref) TArray<FSessionPropertyKeyPair> & NewOrChangedSettings, TArray<FSessionPropertyKeyPair> & ModifiedSettingsArray)
{ {
ModifiedSettingsArray = SettingsArray; ModifiedSettingsArray = SettingsArray;
@@ -62,9 +163,10 @@ void UAdvancedSessionsLibrary::GetExtraSettings(FBlueprintSessionResult SessionR
} }
} }
void UAdvancedSessionsLibrary::GetSessionState(EBPOnlineSessionState &SessionState) void UAdvancedSessionsLibrary::GetSessionState(UObject* WorldContextObject, EBPOnlineSessionState &SessionState)
{ {
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
@@ -72,12 +174,13 @@ void UAdvancedSessionsLibrary::GetSessionState(EBPOnlineSessionState &SessionSta
return; return;
} }
SessionState = ((EBPOnlineSessionState)SessionInterface->GetSessionState(GameSessionName)); SessionState = ((EBPOnlineSessionState)SessionInterface->GetSessionState(NAME_GameSession));
} }
void UAdvancedSessionsLibrary::GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result) void UAdvancedSessionsLibrary::GetSessionSettings(UObject* WorldContextObject, int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result)
{ {
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
@@ -86,7 +189,7 @@ void UAdvancedSessionsLibrary::GetSessionSettings(int32 &NumConnections, int32 &
return; return;
} }
FOnlineSessionSettings* settings = SessionInterface->GetSessionSettings(GameSessionName); FOnlineSessionSettings* settings = SessionInterface->GetSessionSettings(NAME_GameSession);
if (!settings) if (!settings)
{ {
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetSessionSettings couldn't get the session settings!")); UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetSessionSettings couldn't get the session settings!"));
@@ -115,9 +218,10 @@ void UAdvancedSessionsLibrary::GetSessionSettings(int32 &NumConnections, int32 &
Result = EBlueprintResultSwitch::OnSuccess; Result = EBlueprintResultSwitch::OnSuccess;
} }
void UAdvancedSessionsLibrary::IsPlayerInSession(const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession) void UAdvancedSessionsLibrary::IsPlayerInSession(UObject* WorldContextObject, const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession)
{ {
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
if (!SessionInterface.IsValid()) if (!SessionInterface.IsValid())
{ {
@@ -126,7 +230,7 @@ void UAdvancedSessionsLibrary::IsPlayerInSession(const FBPUniqueNetId &PlayerToC
return; return;
} }
bIsInSession = SessionInterface->IsPlayerInSession(GameSessionName, *PlayerToCheck.GetUniqueNetId()); bIsInSession = SessionInterface->IsPlayerInSession(NAME_GameSession, *PlayerToCheck.GetUniqueNetId());
} }
FSessionsSearchSetting UAdvancedSessionsLibrary::MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp) FSessionsSearchSetting UAdvancedSessionsLibrary::MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp)
@@ -338,7 +442,7 @@ void UAdvancedSessionsLibrary::GetUniqueNetID(APlayerController *PlayerControlle
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL) if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
{ {
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId()); UniqueNetId.SetUniqueNetId(PlayerState->GetUniqueId().GetUniqueNetId());
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromController couldn't get the player uniquenetid!")); UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromController couldn't get the player uniquenetid!"));
@@ -355,7 +459,7 @@ void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *Playe
return; return;
} }
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId()); UniqueNetId.SetUniqueNetId(PlayerState->GetUniqueId().GetUniqueNetId());
if (!UniqueNetId.IsValid()) if (!UniqueNetId.IsValid())
{ {
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromPlayerState couldn't get the player uniquenetid!")); UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromPlayerState couldn't get the player uniquenetid!"));
@@ -373,6 +477,11 @@ bool UAdvancedSessionsLibrary::EqualEqual_UNetIDUnetID(const FBPUniqueNetId &A,
return ((A.IsValid() && B.IsValid()) && (*A.GetUniqueNetId() == *B.GetUniqueNetId())); return ((A.IsValid() && B.IsValid()) && (*A.GetUniqueNetId() == *B.GetUniqueNetId()));
} }
FUniqueNetIdRepl UAdvancedSessionsLibrary::Conv_BPUniqueIDToUniqueNetIDRepl(const FBPUniqueNetId& InUniqueID)
{
return FUniqueNetIdRepl(InUniqueID.GetUniqueNetId()->AsShared());
}
void UAdvancedSessionsLibrary::SetPlayerName(APlayerController *PlayerController, FString PlayerName) void UAdvancedSessionsLibrary::SetPlayerName(APlayerController *PlayerController, FString PlayerName)
{ {
if (!PlayerController) if (!PlayerController)
@@ -402,7 +511,7 @@ void UAdvancedSessionsLibrary::GetPlayerName(APlayerController *PlayerController
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL) if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
{ {
PlayerName = PlayerState->PlayerName; PlayerName = PlayerState->GetPlayerName();
return; return;
} }
else else
@@ -413,23 +522,31 @@ void UAdvancedSessionsLibrary::GetPlayerName(APlayerController *PlayerController
void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers) void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextObject, int32 &NumNetPlayers)
{ {
//Get an actor to GetWorld() from
/*TObjectIterator<AActor> Itr;
if (!Itr)
{
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get iterator!"));
return;
}*/
//~~~~~~~~~~~~
//Get World //Get World
UWorld* TheWorld = GEngine->GetWorldFromContextObject(WorldContextObject); UWorld* TheWorld = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!TheWorld) if (!TheWorld)
{ {
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get World()!")); UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get World()!"));
return; return;
} }
TArray<class APlayerState*>& PlayerArray = (TheWorld->GetGameState()->PlayerArray);
NumNetPlayers = PlayerArray.Num(); NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num();
} }
bool UAdvancedSessionsLibrary::ServerTravel(UObject* WorldContextObject, const FString& FURL, bool bAbsolute, bool bShouldSkipGameNotify)
{
if (!WorldContextObject)
{
return false;
}
//using a context object to get the world
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
if (World)
{
return World->ServerTravel(FURL, bAbsolute, bShouldSkipGameNotify);
}
return false;
}

View File

@@ -1,254 +1,359 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedVoiceLibrary.h" #include "AdvancedVoiceLibrary.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedVoiceLog); DEFINE_LOG_CATEGORY(AdvancedVoiceLog);
void UAdvancedVoiceLibrary::IsHeadsetPresent(bool & bHasHeadset, uint8 LocalPlayerNum) void UAdvancedVoiceLibrary::IsHeadsetPresent(UObject* WorldContextObject, bool & bHasHeadset, uint8 LocalPlayerNum)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!VoiceInterface.IsValid()) if (!IsValid(World))
{ {
bHasHeadset = false; return;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Check For Headset couldn't get the voice interface!")); }
return;
} IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum); if (!VoiceInterface.IsValid())
} {
bHasHeadset = false;
void UAdvancedVoiceLibrary::StartNetworkedVoice(uint8 LocalPlayerNum) UE_LOG(AdvancedVoiceLog, Warning, TEXT("Check For Headset couldn't get the voice interface!"));
{ return;
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); }
if (!VoiceInterface.IsValid()) bHasHeadset = VoiceInterface->IsHeadsetPresent(LocalPlayerNum);
{ }
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
return; void UAdvancedVoiceLibrary::StartNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum)
} {
VoiceInterface->StartNetworkedVoice(LocalPlayerNum); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
} if (!IsValid(World))
{
void UAdvancedVoiceLibrary::StopNetworkedVoice(uint8 LocalPlayerNum) return;
{ }
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid())
{ if (!VoiceInterface.IsValid())
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!")); {
return; UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
} return;
}
VoiceInterface->StopNetworkedVoice(LocalPlayerNum);
} VoiceInterface->StartNetworkedVoice(LocalPlayerNum);
}
bool UAdvancedVoiceLibrary::RegisterLocalTalker(uint8 LocalPlayerNum)
{ void UAdvancedVoiceLibrary::StopNetworkedVoice(UObject* WorldContextObject, uint8 LocalPlayerNum)
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); {
if (!VoiceInterface.IsValid()) UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
{ if (!IsValid(World))
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talker couldn't get the voice interface!")); {
return false; return;
} }
return VoiceInterface->RegisterLocalTalker(LocalPlayerNum); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
}
if (!VoiceInterface.IsValid())
void UAdvancedVoiceLibrary::RegisterAllLocalTalkers() {
{ UE_LOG(AdvancedVoiceLog, Warning, TEXT("Start Networked Voice couldn't get the voice interface!"));
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); return;
}
if (!VoiceInterface.IsValid())
{ VoiceInterface->StopNetworkedVoice(LocalPlayerNum);
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talkers couldn't get the voice interface!")); }
return;
} bool UAdvancedVoiceLibrary::RegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum)
{
VoiceInterface->RegisterLocalTalkers(); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
} if (!IsValid(World))
{
return false;
void UAdvancedVoiceLibrary::UnRegisterLocalTalker(uint8 LocalPlayerNum) }
{
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid()) if (!VoiceInterface.IsValid())
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unregister Local Talker couldn't get the voice interface!")); UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talker couldn't get the voice interface!"));
return; return false;
} }
VoiceInterface->UnregisterLocalTalker(LocalPlayerNum); return VoiceInterface->RegisterLocalTalker(LocalPlayerNum);
} }
void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers() void UAdvancedVoiceLibrary::RegisterAllLocalTalkers(UObject* WorldContextObject)
{ {
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!VoiceInterface.IsValid()) if (!IsValid(World))
{ {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister All Local Talkers couldn't get the voice interface!")); return;
return; }
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
VoiceInterface->UnregisterLocalTalkers();
} if (!VoiceInterface.IsValid())
{
bool UAdvancedVoiceLibrary::RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Local Talkers couldn't get the voice interface!"));
{ return;
if (!UniqueNetId.IsValid()) }
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker was passed an invalid unique net id!")); VoiceInterface->RegisterLocalTalkers();
return false; }
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); void UAdvancedVoiceLibrary::UnRegisterLocalTalker(UObject* WorldContextObject, uint8 LocalPlayerNum)
{
if (!VoiceInterface.IsValid())
{ UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker couldn't get the voice interface!")); if (!IsValid(World))
return false; {
} return;
}
return VoiceInterface->RegisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
} IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId) if (!VoiceInterface.IsValid())
{ {
if (!UniqueNetId.IsValid()) UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unregister Local Talker couldn't get the voice interface!"));
{ return;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker was passed an invalid unique net id!")); }
return false;
} VoiceInterface->UnregisterLocalTalker(LocalPlayerNum);
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
void UAdvancedVoiceLibrary::UnRegisterAllLocalTalkers(UObject* WorldContextObject)
if (!VoiceInterface.IsValid()) {
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker couldn't get the voice interface!")); UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
return false; if (!IsValid(World))
} {
return;
return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId()); }
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers()
{ if (!VoiceInterface.IsValid())
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister All Local Talkers couldn't get the voice interface!"));
if (!VoiceInterface.IsValid()) return;
{ }
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Remove All Remote Talkers couldn't get the voice interface!"));
return; VoiceInterface->UnregisterLocalTalkers();
} }
VoiceInterface->RemoveAllRemoteTalkers(); bool UAdvancedVoiceLibrary::RegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
} {
if (!UniqueNetId.IsValid())
bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(uint8 LocalPlayerNum) {
{ UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker was passed an invalid unique net id!"));
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); return false;
}
if (!VoiceInterface.IsValid())
{ UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Local Player Talking couldn't get the voice interface!")); if (!IsValid(World))
return false; {
} return false;
}
return VoiceInterface->IsLocalPlayerTalking(LocalPlayerNum);
} IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(const FBPUniqueNetId& UniqueNetId) if (!VoiceInterface.IsValid())
{ {
if (!UniqueNetId.IsValid()) UE_LOG(AdvancedVoiceLog, Warning, TEXT("Register Remote Talker couldn't get the voice interface!"));
{ return false;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking was passed an invalid unique net id!")); }
return false;
} return VoiceInterface->RegisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
bool UAdvancedVoiceLibrary::UnRegisterRemoteTalker(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
if (!VoiceInterface.IsValid()) {
{ if (!UniqueNetId.IsValid())
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking couldn't get the voice interface!")); {
return false; UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker was passed an invalid unique net id!"));
} return false;
}
return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId());
} UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
bool UAdvancedVoiceLibrary::IsPlayerMuted(uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId) {
{ return false;
if (!UniqueNetId.IsValid()) }
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted was passed an invalid unique net id!")); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
return false;
} if (!VoiceInterface.IsValid())
{
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); UE_LOG(AdvancedVoiceLog, Warning, TEXT("UnRegister Remote Talker couldn't get the voice interface!"));
return false;
if (!VoiceInterface.IsValid()) }
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted couldn't get the voice interface!")); return VoiceInterface->UnregisterRemoteTalker(*UniqueNetId.GetUniqueNetId());
return false; }
}
void UAdvancedVoiceLibrary::RemoveAllRemoteTalkers(UObject* WorldContextObject)
return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId()); {
}
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
bool UAdvancedVoiceLibrary::MuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) if (!IsValid(World))
{ {
if (!UniqueNetId.IsValid()) return;
{ }
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker was passed an invalid unique net id!"));
return false; IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
}
if (!VoiceInterface.IsValid())
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); {
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Remove All Remote Talkers couldn't get the voice interface!"));
if (!VoiceInterface.IsValid()) return;
{ }
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker couldn't get the voice interface!"));
return false; VoiceInterface->RemoveAllRemoteTalkers();
} }
return VoiceInterface->MuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide); bool UAdvancedVoiceLibrary::IsLocalPlayerTalking(UObject* WorldContextObject, uint8 LocalPlayerNum)
} {
bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide) UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
{ if (!IsValid(World))
if (!UniqueNetId.IsValid()) {
{ return false;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker was passed an invalid unique net id!")); }
return false;
} IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); if (!VoiceInterface.IsValid())
{
if (!VoiceInterface.IsValid()) UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Local Player Talking couldn't get the voice interface!"));
{ return false;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!")); }
return false;
} return VoiceInterface->IsLocalPlayerTalking(LocalPlayerNum);
}
return VoiceInterface->UnmuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
} bool UAdvancedVoiceLibrary::IsRemotePlayerTalking(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
{
if (!UniqueNetId.IsValid())
void UAdvancedVoiceLibrary::GetNumLocalTalkers(int32 & NumLocalTalkers) {
{ UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking was passed an invalid unique net id!"));
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(); return false;
}
if (!VoiceInterface.IsValid())
{ UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
NumLocalTalkers = 0; if (!IsValid(World))
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!")); {
return; return false;
} }
NumLocalTalkers = VoiceInterface->GetNumLocalTalkers(); IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid())
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Remote Player Talking couldn't get the voice interface!"));
return false;
}
return VoiceInterface->IsRemotePlayerTalking(*UniqueNetId.GetUniqueNetId());
}
bool UAdvancedVoiceLibrary::IsPlayerMuted(UObject* WorldContextObject, uint8 LocalUserNumChecking, const FBPUniqueNetId& UniqueNetId)
{
if (!UniqueNetId.IsValid())
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted was passed an invalid unique net id!"));
return false;
}
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid())
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Is Player Muted couldn't get the voice interface!"));
return false;
}
return VoiceInterface->IsMuted(LocalUserNumChecking, *UniqueNetId.GetUniqueNetId());
}
bool UAdvancedVoiceLibrary::MuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
{
if (!UniqueNetId.IsValid())
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker was passed an invalid unique net id!"));
return false;
}
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid())
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Mute Remote Talker couldn't get the voice interface!"));
return false;
}
return VoiceInterface->MuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
}
bool UAdvancedVoiceLibrary::UnMuteRemoteTalker(UObject* WorldContextObject, uint8 LocalUserNum, const FBPUniqueNetId& UniqueNetId, bool bIsSystemWide)
{
if (!UniqueNetId.IsValid())
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker was passed an invalid unique net id!"));
return false;
}
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return false;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid())
{
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
return false;
}
return VoiceInterface->UnmuteRemoteTalker(LocalUserNum, *UniqueNetId.GetUniqueNetId(), bIsSystemWide);
}
void UAdvancedVoiceLibrary::GetNumLocalTalkers(UObject* WorldContextObject, int32 & NumLocalTalkers)
{
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
if (!IsValid(World))
{
return;
}
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(World);
if (!VoiceInterface.IsValid())
{
NumLocalTalkers = 0;
UE_LOG(AdvancedVoiceLog, Warning, TEXT("Unmute Remote Talker couldn't get the voice interface!"));
return;
}
NumLocalTalkers = VoiceInterface->GetNumLocalTalkers();
} }

View File

@@ -0,0 +1,89 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "AutoLoginUserCallbackProxy.h"
#include "Kismet/GameplayStatics.h"
#include "Online.h"
//////////////////////////////////////////////////////////////////////////
// ULoginUserCallbackProxy
UAutoLoginUserCallbackProxy::UAutoLoginUserCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, Delegate(FOnLoginCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
{
}
UAutoLoginUserCallbackProxy* UAutoLoginUserCallbackProxy::AutoLoginUser(UObject* WorldContextObject, int32 LocalUserNum)
{
UAutoLoginUserCallbackProxy* Proxy = NewObject<UAutoLoginUserCallbackProxy>();
Proxy->LocalUserNumber = LocalUserNum;
Proxy->WorldContextObject = WorldContextObject;
return Proxy;
}
void UAutoLoginUserCallbackProxy::Activate()
{
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("AutoLoginUser"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (Helper.OnlineSub != nullptr)
{
auto Identity = Helper.OnlineSub->GetIdentityInterface();
if (Identity.IsValid())
{
DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(LocalUserNumber, Delegate);
Identity->AutoLogin(LocalUserNumber);
return;
}
}
// Fail immediately
OnFailure.Broadcast();
}
void UAutoLoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& ErrorVal)
{
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("AutoLoginUser"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (Helper.OnlineSub != nullptr)
{
auto Identity = Helper.OnlineSub->GetIdentityInterface();
if (Identity.IsValid())
{
Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, DelegateHandle);
}
if (APlayerController* PController = UGameplayStatics::GetPlayerController(WorldContextObject->GetWorld(), LocalUserNum))
{
ULocalPlayer* Player = Cast<ULocalPlayer>(PController->Player);
FUniqueNetIdRepl uniqueId(UserId.AsShared());
if (Player)
{
Player->SetCachedUniqueNetId(uniqueId);
}
if (APlayerState* State = PController->PlayerState)
{
// Update UniqueId. See also ShowLoginUICallbackProxy.cpp
State->SetUniqueId(uniqueId);
}
}
if (bWasSuccessful)
{
OnSuccess.Broadcast();
}
else
{
OnFailure.Broadcast();
}
}
OnFailure.Broadcast();
}

View File

@@ -1,5 +1,4 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "CancelFindSessionsCallbackProxy.h" #include "CancelFindSessionsCallbackProxy.h"
@@ -22,7 +21,7 @@ UCancelFindSessionsCallbackProxy* UCancelFindSessionsCallbackProxy::CancelFindSe
void UCancelFindSessionsCallbackProxy::Activate() void UCancelFindSessionsCallbackProxy::Activate()
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CancelFindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CancelFindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.IsValid()) if (Helper.IsValid())
@@ -48,7 +47,7 @@ void UCancelFindSessionsCallbackProxy::Activate()
void UCancelFindSessionsCallbackProxy::OnCompleted(bool bWasSuccessful) void UCancelFindSessionsCallbackProxy::OnCompleted(bool bWasSuccessful)
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CancelFindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CancelFindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.IsValid()) if (Helper.IsValid())

View File

@@ -13,7 +13,7 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F
{ {
} }
UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise) UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair>& ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bUseLobbiesIfAvailable, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise, bool bUseLobbiesVoiceChatIfAvailable, bool bStartAfterCreate)
{ {
UCreateSessionCallbackProxyAdvanced* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>(); UCreateSessionCallbackProxyAdvanced* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
@@ -25,17 +25,20 @@ UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::Create
Proxy->ExtraSettings = ExtraSettings; Proxy->ExtraSettings = ExtraSettings;
Proxy->bDedicatedServer = bIsDedicatedServer; Proxy->bDedicatedServer = bIsDedicatedServer;
Proxy->bUsePresence = bUsePresence; Proxy->bUsePresence = bUsePresence;
Proxy->bUseLobbiesIfAvailable = bUseLobbiesIfAvailable;
Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence; Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence;
Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
Proxy->bAntiCheatProtected = bAntiCheatProtected; Proxy->bAntiCheatProtected = bAntiCheatProtected;
Proxy->bUsesStats = bUsesStats; Proxy->bUsesStats = bUsesStats;
Proxy->bShouldAdvertise = bShouldAdvertise; Proxy->bShouldAdvertise = bShouldAdvertise;
Proxy->bUseLobbiesVoiceChatIfAvailable = bUseLobbiesVoiceChatIfAvailable;
Proxy->bStartAfterCreate = bStartAfterCreate;
return Proxy; return Proxy;
} }
void UCreateSessionCallbackProxyAdvanced::Activate() void UCreateSessionCallbackProxyAdvanced::Activate()
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CreateSession"), GEngine->GetWorldFromContextObject(WorldContextObject)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CreateSession"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (PlayerControllerWeakPtr.IsValid() ) if (PlayerControllerWeakPtr.IsValid() )
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
@@ -50,21 +53,27 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
FOnlineSessionSettings Settings; FOnlineSessionSettings Settings;
Settings.NumPublicConnections = NumPublicConnections; Settings.NumPublicConnections = NumPublicConnections;
Settings.NumPrivateConnections = NumPrivateConnections; Settings.NumPrivateConnections = NumPrivateConnections;
Settings.bShouldAdvertise = true; Settings.bShouldAdvertise = bShouldAdvertise;
Settings.bAllowJoinInProgress = true; Settings.bAllowJoinInProgress = true;
Settings.bIsLANMatch = bUseLAN; Settings.bIsLANMatch = bUseLAN;
Settings.bAllowJoinViaPresence = true; Settings.bAllowJoinViaPresence = bAllowJoinViaPresence;
Settings.bIsDedicated = bDedicatedServer; Settings.bIsDedicated = bDedicatedServer;
if (bDedicatedServer) if (bDedicatedServer)
{
Settings.bUsesPresence = false; Settings.bUsesPresence = false;
Settings.bUseLobbiesIfAvailable = false;
}
else else
{
Settings.bUsesPresence = bUsePresence; Settings.bUsesPresence = bUsePresence;
Settings.bUseLobbiesIfAvailable = bUseLobbiesIfAvailable;
}
Settings.bUseLobbiesVoiceChatIfAvailable = bUseLobbiesIfAvailable ? bUseLobbiesVoiceChatIfAvailable : false;
Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
Settings.bAntiCheatProtected = bAntiCheatProtected; Settings.bAntiCheatProtected = bAntiCheatProtected;
Settings.bUsesStats = bUsesStats; Settings.bUsesStats = bUsesStats;
Settings.bShouldAdvertise = bShouldAdvertise;
// These are about the only changes over the standard Create Sessions Node // These are about the only changes over the standard Create Sessions Node
Settings.bAllowInvites = bAllowInvites; Settings.bAllowInvites = bAllowInvites;
@@ -79,10 +88,23 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
} }
if (!bDedicatedServer && PlayerControllerWeakPtr.IsValid() && Helper.UserID.IsValid()) if (!bDedicatedServer )
Sessions->CreateSession(*Helper.UserID, GameSessionName, Settings); {
if (PlayerControllerWeakPtr.IsValid() && Helper.UserID.IsValid())
{
Sessions->CreateSession(*Helper.UserID, NAME_GameSession, Settings);
}
else
{
FFrame::KismetExecutionMessage(TEXT("Invalid Player controller when attempting to start a session"), ELogVerbosity::Warning);
Sessions->ClearOnCreateSessionCompleteDelegate_Handle(CreateCompleteDelegateHandle);
// Fail immediately
OnFailure.Broadcast();
}
}
else else
Sessions->CreateSession(0, GameSessionName, Settings); Sessions->CreateSession(0, NAME_GameSession, Settings);
// OnCreateCompleted will get called, nothing more to do now // OnCreateCompleted will get called, nothing more to do now
return; return;
@@ -99,7 +121,7 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, bool bWasSuccessful) void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, bool bWasSuccessful)
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CreateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("CreateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
//Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); //Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.OnlineSub != nullptr) if (Helper.OnlineSub != nullptr)
@@ -111,8 +133,17 @@ void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, b
if (bWasSuccessful) if (bWasSuccessful)
{ {
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate); if (this->bStartAfterCreate)
Sessions->StartSession(GameSessionName); {
UE_LOG_ONLINE_SESSION(Display, TEXT("Session creation completed. Automatic start is turned on, starting session now."));
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
Sessions->StartSession(NAME_GameSession); // We'll call `OnSuccess.Broadcast()` when start succeeds.
}
else
{
UE_LOG_ONLINE_SESSION(Display, TEXT("Session creation completed. Automatic start is turned off, to start the session call 'StartSession'."));
OnSuccess.Broadcast();
}
// OnStartCompleted will get called, nothing more to do now // OnStartCompleted will get called, nothing more to do now
return; return;
@@ -128,8 +159,8 @@ void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, b
void UCreateSessionCallbackProxyAdvanced::OnStartCompleted(FName SessionName, bool bWasSuccessful) void UCreateSessionCallbackProxyAdvanced::OnStartCompleted(FName SessionName, bool bWasSuccessful)
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("StartSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("StartSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); //Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.OnlineSub != nullptr) if (Helper.OnlineSub != nullptr)
{ {

View File

@@ -1,5 +1,4 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "EndSessionCallbackProxy.h" #include "EndSessionCallbackProxy.h"
@@ -22,7 +21,7 @@ UEndSessionCallbackProxy* UEndSessionCallbackProxy::EndSession(UObject* WorldCon
void UEndSessionCallbackProxy::Activate() void UEndSessionCallbackProxy::Activate()
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSession"), GEngine->GetWorldFromContextObject(WorldContextObject)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSession"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.IsValid()) if (Helper.IsValid())
@@ -30,12 +29,12 @@ void UEndSessionCallbackProxy::Activate()
auto Sessions = Helper.OnlineSub->GetSessionInterface(); auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (Sessions.IsValid()) if (Sessions.IsValid())
{ {
FNamedOnlineSession* Session = Sessions->GetNamedSession(GameSessionName); FNamedOnlineSession* Session = Sessions->GetNamedSession(NAME_GameSession);
if (Session && if (Session &&
Session->SessionState == EOnlineSessionState::InProgress) Session->SessionState == EOnlineSessionState::InProgress)
{ {
DelegateHandle = Sessions->AddOnEndSessionCompleteDelegate_Handle(Delegate); DelegateHandle = Sessions->AddOnEndSessionCompleteDelegate_Handle(Delegate);
Sessions->EndSession(GameSessionName); Sessions->EndSession(NAME_GameSession);
} }
else else
{ {
@@ -56,7 +55,7 @@ void UEndSessionCallbackProxy::Activate()
void UEndSessionCallbackProxy::OnCompleted(FName SessionName, bool bWasSuccessful) void UEndSessionCallbackProxy::OnCompleted(FName SessionName, bool bWasSuccessful)
{ {
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject)); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.IsValid()) if (Helper.IsValid())

View File

@@ -1,107 +1,130 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "FindFriendSessionCallbackProxy.h" #include "FindFriendSessionCallbackProxy.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UGetRecentPlayersCallbackProxy // UGetRecentPlayersCallbackProxy
DEFINE_LOG_CATEGORY(AdvancedFindFriendSessionLog); DEFINE_LOG_CATEGORY(AdvancedFindFriendSessionLog);
UFindFriendSessionCallbackProxy::UFindFriendSessionCallbackProxy(const FObjectInitializer& ObjectInitializer) UFindFriendSessionCallbackProxy::UFindFriendSessionCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, OnFindFriendSessionCompleteDelegate(FOnFindFriendSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnFindFriendSessionCompleted)) , OnFindFriendSessionCompleteDelegate(FOnFindFriendSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnFindFriendSessionCompleted))
{ {
} }
UFindFriendSessionCallbackProxy* UFindFriendSessionCallbackProxy::FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId) UFindFriendSessionCallbackProxy* UFindFriendSessionCallbackProxy::FindFriendSession(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &FriendUniqueNetId)
{ {
UFindFriendSessionCallbackProxy* Proxy = NewObject<UFindFriendSessionCallbackProxy>(); UFindFriendSessionCallbackProxy* Proxy = NewObject<UFindFriendSessionCallbackProxy>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->cUniqueNetId = FriendUniqueNetId; Proxy->cUniqueNetId = FriendUniqueNetId;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
return Proxy; return Proxy;
} }
void UFindFriendSessionCallbackProxy::Activate() void UFindFriendSessionCallbackProxy::Activate()
{ {
if (!cUniqueNetId.IsValid()) if (!cUniqueNetId.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad UniqueNetId!")); UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad UniqueNetId!"));
TArray<FBlueprintSessionResult> EmptyResult; TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); OnFailure.Broadcast(EmptyResult);
return; return;
} }
if (!PlayerControllerWeakPtr.IsValid()) if (!PlayerControllerWeakPtr.IsValid())
{ {
// Fail immediately // Fail immediately
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad playercontroller!")); UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed received a bad playercontroller!"));
TArray<FBlueprintSessionResult> EmptyResult; TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); OnFailure.Broadcast(EmptyResult);
return; return;
} }
IOnlineSessionPtr Sessions = Online::GetSessionInterface(); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Sessions.IsValid())
{ if (!Helper.IsValid())
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); {
// Fail immediately
if (!Player) TArray<FBlueprintSessionResult> EmptyResult;
{ OnFailure.Broadcast(EmptyResult);
// Fail immediately return;
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed couldn't cast to ULocalPlayer!")); }
TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult); IOnlineSessionPtr Sessions = Helper.OnlineSub->GetSessionInterface();
return;
} if (Sessions.IsValid())
{
FindFriendSessionCompleteDelegateHandle = Sessions->AddOnFindFriendSessionCompleteDelegate_Handle(Player->GetControllerId(), OnFindFriendSessionCompleteDelegate); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
Sessions->FindFriendSession(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId()); if (!Player)
{
return; // Fail immediately
} UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed couldn't cast to ULocalPlayer!"));
TArray<FBlueprintSessionResult> EmptyResult;
// Fail immediately OnFailure.Broadcast(EmptyResult);
TArray<FBlueprintSessionResult> EmptyResult; return;
OnFailure.Broadcast(EmptyResult); }
}
FindFriendSessionCompleteDelegateHandle = Sessions->AddOnFindFriendSessionCompleteDelegate_Handle(Player->GetControllerId(), OnFindFriendSessionCompleteDelegate);
void UFindFriendSessionCallbackProxy::OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo) Sessions->FindFriendSession(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId());
{
IOnlineSessionPtr Sessions = Online::GetSessionInterface(); return;
}
if (Sessions.IsValid())
Sessions->ClearOnFindFriendSessionCompleteDelegate_Handle(LocalPlayer, FindFriendSessionCompleteDelegateHandle); // Fail immediately
TArray<FBlueprintSessionResult> EmptyResult;
if ( bWasSuccessful ) OnFailure.Broadcast(EmptyResult);
{ }
TArray<FBlueprintSessionResult> Result;
for (auto& Sesh : SessionInfo) void UFindFriendSessionCallbackProxy::OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo)
{ {
if (Sesh.IsValid()) FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("EndSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
{ Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
FBlueprintSessionResult BSesh;
BSesh.OnlineResult = Sesh; if (Helper.IsValid())
Result.Add(BSesh); {
} IOnlineSessionPtr Sessions = Helper.OnlineSub->GetSessionInterface();
}
if (Sessions.IsValid())
if(Result.Num() > 0) Sessions->ClearOnFindFriendSessionCompleteDelegate_Handle(LocalPlayer, FindFriendSessionCompleteDelegateHandle);
OnSuccess.Broadcast(Result);
else if (bWasSuccessful)
{ {
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed, returned an invalid session.")); TArray<FBlueprintSessionResult> Result;
OnFailure.Broadcast(Result);
} for (auto& Sesh : SessionInfo)
} {
else if (Sesh.IsValid())
{ {
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed")); FBlueprintSessionResult BSesh;
TArray<FBlueprintSessionResult> EmptyResult; BSesh.OnlineResult = Sesh;
OnFailure.Broadcast(EmptyResult); Result.Add(BSesh);
} }
} }
if (Result.Num() > 0)
OnSuccess.Broadcast(Result);
else
{
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed, returned an invalid session."));
OnFailure.Broadcast(Result);
}
}
else
{
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed"));
TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult);
}
}
else
{
UE_LOG(AdvancedFindFriendSessionLog, Warning, TEXT("FindFriendSession Failed"));
TArray<FBlueprintSessionResult> EmptyResult;
OnFailure.Broadcast(EmptyResult);
}
}

View File

@@ -1,414 +1,444 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "FindSessionsCallbackProxyAdvanced.h"
#include "FindSessionsCallbackProxyAdvanced.h"
#include "Online/OnlineSessionNames.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UFindSessionsCallbackProxyAdvanced // UFindSessionsCallbackProxyAdvanced
UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer) UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) : Super(ObjectInitializer)
, Delegate(FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted)) , Delegate(FOnFindSessionsCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted))
, bUseLAN(false) , bUseLAN(false)
{ {
bRunSecondSearch = false; bRunSecondSearch = false;
bIsOnSecondSearch = false; bIsOnSecondSearch = false;
} }
UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, int MinSlotsAvailable) UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, bool bSearchLobbies, int MinSlotsAvailable)
{ {
UFindSessionsCallbackProxyAdvanced* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>(); UFindSessionsCallbackProxyAdvanced* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->bUseLAN = bUseLAN; Proxy->bUseLAN = bUseLAN;
Proxy->MaxResults = MaxResults; Proxy->MaxResults = MaxResults;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
Proxy->SearchSettings = Filters; Proxy->SearchSettings = Filters;
Proxy->ServerSearchType = ServerTypeToSearch; Proxy->ServerSearchType = ServerTypeToSearch;
Proxy->bEmptyServersOnly = bEmptyServersOnly, Proxy->bEmptyServersOnly = bEmptyServersOnly,
Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly; Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly;
Proxy->bSecureServersOnly = bSecureServersOnly; Proxy->bSecureServersOnly = bSecureServersOnly;
Proxy->MinSlotsAvailable = MinSlotsAvailable; Proxy->bSearchLobbies = bSearchLobbies;
return Proxy; Proxy->MinSlotsAvailable = MinSlotsAvailable;
} return Proxy;
}
void UFindSessionsCallbackProxyAdvanced::Activate()
{ void UFindSessionsCallbackProxyAdvanced::Activate()
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject)); {
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessions"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
if (Helper.IsValid())
{ if (Helper.IsValid())
auto Sessions = Helper.OnlineSub->GetSessionInterface(); {
if (Sessions.IsValid()) auto Sessions = Helper.OnlineSub->GetSessionInterface();
{ if (Sessions.IsValid())
// Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed {
bRunSecondSearch = false; // Re-initialize here, otherwise I think there might be issues with people re-calling search for some reason before it is destroyed
bIsOnSecondSearch = false; bRunSecondSearch = false;
bIsOnSecondSearch = false;
DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate);
DelegateHandle = Sessions->AddOnFindSessionsCompleteDelegate_Handle(Delegate);
SearchObject = MakeShareable(new FOnlineSessionSearch);
SearchObject->MaxSearchResults = MaxResults; SearchObject = MakeShareable(new FOnlineSessionSearch);
SearchObject->bIsLanQuery = bUseLAN; SearchObject->MaxSearchResults = MaxResults;
//SearchObject->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); SearchObject->bIsLanQuery = bUseLAN;
//SearchObject->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
// Create temp filter variable, because I had to re-define a blueprint version of this, it is required.
FOnlineSearchSettingsEx tem; // Create temp filter variable, because I had to re-define a blueprint version of this, it is required.
FOnlineSearchSettingsEx tem;
/* // Search only for dedicated servers (value is true/false)
#define SEARCH_DEDICATED_ONLY FName(TEXT("DEDICATEDONLY")) /* // Search only for dedicated servers (value is true/false)
// Search for empty servers only (value is true/false) #define SEARCH_DEDICATED_ONLY FName(TEXT("DEDICATEDONLY"))
#define SEARCH_EMPTY_SERVERS_ONLY FName(TEXT("EMPTYONLY")) // Search for empty servers only (value is true/false)
// Search for non empty servers only (value is true/false) #define SEARCH_EMPTY_SERVERS_ONLY FName(TEXT("EMPTYONLY"))
#define SEARCH_NONEMPTY_SERVERS_ONLY FName(TEXT("NONEMPTYONLY")) // Search for non empty servers only (value is true/false)
// Search for secure servers only (value is true/false) #define SEARCH_NONEMPTY_SERVERS_ONLY FName(TEXT("NONEMPTYONLY"))
#define SEARCH_SECURE_SERVERS_ONLY FName(TEXT("SECUREONLY")) // Search for secure servers only (value is true/false)
// Search for presence sessions only (value is true/false) #define SEARCH_SECURE_SERVERS_ONLY FName(TEXT("SECUREONLY"))
#define SEARCH_PRESENCE FName(TEXT("PRESENCESEARCH")) // Search for presence sessions only (value is true/false)
// Search for a match with min player availability (value is int) #define SEARCH_PRESENCE FName(TEXT("PRESENCESEARCH"))
#define SEARCH_MINSLOTSAVAILABLE FName(TEXT("MINSLOTSAVAILABLE")) // Search for a match with min player availability (value is int)
// Exclude all matches where any unique ids in a given array are present (value is string of the form "uniqueid1;uniqueid2;uniqueid3") #define SEARCH_MINSLOTSAVAILABLE FName(TEXT("MINSLOTSAVAILABLE"))
#define SEARCH_EXCLUDE_UNIQUEIDS FName(TEXT("EXCLUDEUNIQUEIDS")) // Exclude all matches where any unique ids in a given array are present (value is string of the form "uniqueid1;uniqueid2;uniqueid3")
// User ID to search for session of #define SEARCH_EXCLUDE_UNIQUEIDS FName(TEXT("EXCLUDEUNIQUEIDS"))
#define SEARCH_USER FName(TEXT("SEARCHUSER")) // User ID to search for session of
// Keywords to match in session search #define SEARCH_USER FName(TEXT("SEARCHUSER"))
#define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/ // Keywords to match in session search
#define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/
if (bEmptyServersOnly) /** Keywords to match in session search */
tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); /** The matchmaking queue name to matchmake in, e.g. "TeamDeathmatch" (value is string) */
/** #define SEARCH_MATCHMAKING_QUEUE FName(TEXT("MATCHMAKINGQUEUE"))*/
if (bNonEmptyServersOnly) /** If set, use the named Xbox Live hopper to find a session via matchmaking (value is a string) */
tem.Set(SEARCH_NONEMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); /** #define SEARCH_XBOX_LIVE_HOPPER_NAME FName(TEXT("LIVEHOPPERNAME"))*/
/** Which session template from the service configuration to use */
if (bSecureServersOnly) /** #define SEARCH_XBOX_LIVE_SESSION_TEMPLATE_NAME FName(TEXT("LIVESESSIONTEMPLATE"))*/
tem.Set(SEARCH_SECURE_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); /** Selection method used to determine which match to join when multiple are returned (valid only on Switch) */
/** #define SEARCH_SWITCH_SELECTION_METHOD FName(TEXT("SWITCHSELECTIONMETHOD"))*/
if (MinSlotsAvailable != 0) /** Whether to use lobbies vs sessions */
tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals); /** #define SEARCH_LOBBIES FName(TEXT("LOBBYSEARCH"))*/
if (bEmptyServersOnly)
tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
// Filter results
if (SearchSettings.Num() > 0) if (bNonEmptyServersOnly)
{ tem.Set(SEARCH_NONEMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
for (int i = 0; i < SearchSettings.Num(); i++)
{ if (bSecureServersOnly)
// Function that was added to make directly adding a FVariant possible tem.Set(SEARCH_SECURE_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
tem.HardSet(SearchSettings[i].PropertyKeyPair.Key, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp);
} if (MinSlotsAvailable != 0)
} tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals);
switch (ServerSearchType) // Filter results
{ if (SearchSettings.Num() > 0)
{
case EBPServerPresenceSearchType::ClientServersOnly: for (int i = 0; i < SearchSettings.Num(); i++)
{ {
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); // Function that was added to make directly adding a FVariant possible
} tem.HardSet(SearchSettings[i].PropertyKeyPair.Key, SearchSettings[i].PropertyKeyPair.Data, SearchSettings[i].ComparisonOp);
break; }
}
case EBPServerPresenceSearchType::DedicatedServersOnly:
{ switch (ServerSearchType)
//tem.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals); {
}
break; case EBPServerPresenceSearchType::ClientServersOnly:
{
case EBPServerPresenceSearchType::AllServers: tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
default:
{ if (bSearchLobbies && !IOnlineSubsystem::DoesInstanceExist("STEAM"))
// Only steam uses the separate searching flags currently tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
if (IOnlineSubsystem::DoesInstanceExist("STEAM")) }
{ break;
bRunSecondSearch = true;
case EBPServerPresenceSearchType::DedicatedServersOnly:
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch); {
SearchObjectDedicated->MaxSearchResults = MaxResults; //tem.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
SearchObjectDedicated->bIsLanQuery = bUseLAN; }
break;
FOnlineSearchSettingsEx DedicatedOnly = tem;
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); case EBPServerPresenceSearchType::AllServers:
default:
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals); {
SearchObjectDedicated->QuerySettings = DedicatedOnly; //if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
} //{
} bRunSecondSearch = true;
break;
} SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
SearchObjectDedicated->MaxSearchResults = MaxResults;
// Copy the derived temp variable over to it's base class SearchObjectDedicated->bIsLanQuery = bUseLAN;
SearchObject->QuerySettings = tem;
FOnlineSearchSettingsEx DedicatedOnly = tem;
Sessions->FindSessions(*Helper.UserID, SearchObject.ToSharedRef());
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
// OnQueryCompleted will get called, nothing more to do now
return; if (bSearchLobbies && !IOnlineSubsystem::DoesInstanceExist("STEAM"))
} tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
else
{ //DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning); SearchObjectDedicated->QuerySettings = DedicatedOnly;
} //}
} }
break;
// Fail immediately }
OnFailure.Broadcast(SessionSearchResults);
} // Copy the derived temp variable over to it's base class
SearchObject->QuerySettings = tem;
void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
{ Sessions->FindSessions(*Helper.UserID, SearchObject.ToSharedRef());
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get()); // OnQueryCompleted will get called, nothing more to do now
return;
if (!bRunSecondSearch && Helper.IsValid()) }
{ else
auto Sessions = Helper.OnlineSub->GetSessionInterface(); {
if (Sessions.IsValid()) FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
{ }
Sessions->ClearOnFindSessionsCompleteDelegate_Handle(DelegateHandle); }
}
} // Fail immediately
OnFailure.Broadcast(SessionSearchResults);
if (bSuccess) }
{
if (bIsOnSecondSearch) void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
{ {
if (SearchObjectDedicated.IsValid()) FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("FindSessionsCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
{ Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
// Just log the results for now, will need to add a blueprint-compatible search result struct
for (auto& Result : SearchObjectDedicated->SearchResults) if (!Helper.IsValid())
{ {
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs); // Fail immediately
OnFailure.Broadcast(SessionSearchResults);
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log); return;
}
FBlueprintSessionResult BPResult;
BPResult.OnlineResult = Result; if (!bRunSecondSearch && Helper.IsValid())
SessionSearchResults.Add(BPResult); {
} auto Sessions = Helper.OnlineSub->GetSessionInterface();
OnSuccess.Broadcast(SessionSearchResults); if (Sessions.IsValid())
return; {
} Sessions->ClearOnFindSessionsCompleteDelegate_Handle(DelegateHandle);
} }
else }
{
if (SearchObject.IsValid()) if (bSuccess)
{ {
// Just log the results for now, will need to add a blueprint-compatible search result struct if (bIsOnSecondSearch)
for (auto& Result : SearchObject->SearchResults) {
{ if (SearchObjectDedicated.IsValid())
FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs); {
// Just log the results for now, will need to add a blueprint-compatible search result struct
FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log); for (auto& Result : SearchObjectDedicated->SearchResults)
{
FBlueprintSessionResult BPResult; FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
BPResult.OnlineResult = Result;
SessionSearchResults.Add(BPResult); FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
}
if (!bRunSecondSearch) FBlueprintSessionResult BPResult;
{ BPResult.OnlineResult = Result;
OnSuccess.Broadcast(SessionSearchResults); SessionSearchResults.AddUnique(BPResult);
return; }
} OnSuccess.Broadcast(SessionSearchResults);
} return;
} }
} }
else else
{ {
if (!bRunSecondSearch) if (SearchObject.IsValid())
{ {
// Need to account for only one of the searches failing // Just log the results for now, will need to add a blueprint-compatible search result struct
if (SessionSearchResults.Num() > 0) for (auto& Result : SearchObject->SearchResults)
OnSuccess.Broadcast(SessionSearchResults); {
else FString ResultText = FString::Printf(TEXT("Found a session. Ping is %d"), Result.PingInMs);
OnFailure.Broadcast(SessionSearchResults);
return; FFrame::KismetExecutionMessage(*ResultText, ELogVerbosity::Log);
}
} FBlueprintSessionResult BPResult;
BPResult.OnlineResult = Result;
if (bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers) SessionSearchResults.AddUnique(BPResult);
{ }
bRunSecondSearch = false; if (!bRunSecondSearch)
bIsOnSecondSearch = true; {
auto Sessions = Helper.OnlineSub->GetSessionInterface(); OnSuccess.Broadcast(SessionSearchResults);
Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef()); return;
} }
} }
}
}
void UFindSessionsCallbackProxyAdvanced::FilterSessionResults(const TArray<FBlueprintSessionResult> &SessionResults, const TArray<FSessionsSearchSetting> &Filters, TArray<FBlueprintSessionResult> &FilteredResults) else
{ {
for (int j = 0; j < SessionResults.Num(); j++) if (!bRunSecondSearch)
{ {
bool bAddResult = true; // Need to account for only one of the searches failing
if (SessionSearchResults.Num() > 0)
// Filter results OnSuccess.Broadcast(SessionSearchResults);
if (Filters.Num() > 0) else
{ OnFailure.Broadcast(SessionSearchResults);
const FOnlineSessionSetting * setting; return;
for (int i = 0; i < Filters.Num(); i++) }
{ }
setting = SessionResults[j].OnlineResult.Session.SessionSettings.Settings.Find(Filters[i].PropertyKeyPair.Key);
if (Helper.IsValid() && bRunSecondSearch && ServerSearchType == EBPServerPresenceSearchType::AllServers)
// Couldn't find this key {
if (!setting) bRunSecondSearch = false;
continue; bIsOnSecondSearch = true;
auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (!CompareVariants(setting->Data, Filters[i].PropertyKeyPair.Data, Filters[i].ComparisonOp)) Sessions->FindSessions(*Helper.UserID, SearchObjectDedicated.ToSharedRef());
{ }
bAddResult = false; else // We lost our player controller
break; {
} if (bSuccess && SessionSearchResults.Num() > 0)
} OnSuccess.Broadcast(SessionSearchResults);
} else
OnFailure.Broadcast(SessionSearchResults);
if (bAddResult) }
FilteredResults.Add(SessionResults[j]); }
}
return; void UFindSessionsCallbackProxyAdvanced::FilterSessionResults(const TArray<FBlueprintSessionResult> &SessionResults, const TArray<FSessionsSearchSetting> &Filters, TArray<FBlueprintSessionResult> &FilteredResults)
} {
for (int j = 0; j < SessionResults.Num(); j++)
{
bool UFindSessionsCallbackProxyAdvanced::CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator) bool bAddResult = true;
{
if (A.GetType() != B.GetType()) // Filter results
return false; if (Filters.Num() > 0)
{
switch (A.GetType()) const FOnlineSessionSetting * setting;
{ for (int i = 0; i < Filters.Num(); i++)
case EOnlineKeyValuePairDataType::Bool: {
{ setting = SessionResults[j].OnlineResult.Session.SessionSettings.Settings.Find(Filters[i].PropertyKeyPair.Key);
bool bA, bB;
A.GetValue(bA); // Couldn't find this key
B.GetValue(bB); if (!setting)
switch (Comparator) continue;
{
case EOnlineComparisonOpRedux::Equals: if (!CompareVariants(setting->Data, Filters[i].PropertyKeyPair.Data, Filters[i].ComparisonOp))
return bA == bB; break; {
case EOnlineComparisonOpRedux::NotEquals: bAddResult = false;
return bA != bB; break; break;
default: }
return false;break; }
} }
}
case EOnlineKeyValuePairDataType::Double: if (bAddResult)
{ FilteredResults.Add(SessionResults[j]);
double bA, bB; }
A.GetValue(bA);
B.GetValue(bB); return;
switch (Comparator) }
{
case EOnlineComparisonOpRedux::Equals:
return bA == bB; break; bool UFindSessionsCallbackProxyAdvanced::CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator)
case EOnlineComparisonOpRedux::NotEquals: {
return bA != bB; break; if (A.GetType() != B.GetType())
case EOnlineComparisonOpRedux::GreaterThanEquals: return false;
return (bA == bB || bA > bB); break;
case EOnlineComparisonOpRedux::LessThanEquals: switch (A.GetType())
return (bA == bB || bA < bB); break; {
case EOnlineComparisonOpRedux::GreaterThan: case EOnlineKeyValuePairDataType::Bool:
return bA > bB; break; {
case EOnlineComparisonOpRedux::LessThan: bool bA, bB;
return bA < bB; break; A.GetValue(bA);
default: B.GetValue(bB);
return false; break; switch (Comparator)
} {
} case EOnlineComparisonOpRedux::Equals:
case EOnlineKeyValuePairDataType::Float: return bA == bB; break;
{ case EOnlineComparisonOpRedux::NotEquals:
float tbA, tbB; return bA != bB; break;
double bA, bB; default:
A.GetValue(tbA); return false;break;
B.GetValue(tbB); }
bA = (double)tbA; }
bB = (double)tbB; case EOnlineKeyValuePairDataType::Double:
switch (Comparator) {
{ double bA, bB;
case EOnlineComparisonOpRedux::Equals: A.GetValue(bA);
return bA == bB; break; B.GetValue(bB);
case EOnlineComparisonOpRedux::NotEquals: switch (Comparator)
return bA != bB; break; {
case EOnlineComparisonOpRedux::GreaterThanEquals: case EOnlineComparisonOpRedux::Equals:
return (bA == bB || bA > bB); break; return bA == bB; break;
case EOnlineComparisonOpRedux::LessThanEquals: case EOnlineComparisonOpRedux::NotEquals:
return (bA == bB || bA < bB); break; return bA != bB; break;
case EOnlineComparisonOpRedux::GreaterThan: case EOnlineComparisonOpRedux::GreaterThanEquals:
return bA > bB; break; return (bA == bB || bA > bB); break;
case EOnlineComparisonOpRedux::LessThan: case EOnlineComparisonOpRedux::LessThanEquals:
return bA < bB; break; return (bA == bB || bA < bB); break;
default: case EOnlineComparisonOpRedux::GreaterThan:
return false; break; return bA > bB; break;
} case EOnlineComparisonOpRedux::LessThan:
} return bA < bB; break;
case EOnlineKeyValuePairDataType::Int32: default:
{ return false; break;
int32 bA, bB; }
A.GetValue(bA); }
B.GetValue(bB); case EOnlineKeyValuePairDataType::Float:
switch (Comparator) {
{ float tbA, tbB;
case EOnlineComparisonOpRedux::Equals: double bA, bB;
return bA == bB; break; A.GetValue(tbA);
case EOnlineComparisonOpRedux::NotEquals: B.GetValue(tbB);
return bA != bB; break; bA = (double)tbA;
case EOnlineComparisonOpRedux::GreaterThanEquals: bB = (double)tbB;
return (bA == bB || bA > bB); break; switch (Comparator)
case EOnlineComparisonOpRedux::LessThanEquals: {
return (bA == bB || bA < bB); break; case EOnlineComparisonOpRedux::Equals:
case EOnlineComparisonOpRedux::GreaterThan: return bA == bB; break;
return bA > bB; break; case EOnlineComparisonOpRedux::NotEquals:
case EOnlineComparisonOpRedux::LessThan: return bA != bB; break;
return bA < bB; break; case EOnlineComparisonOpRedux::GreaterThanEquals:
default: return (bA == bB || bA > bB); break;
return false; break; case EOnlineComparisonOpRedux::LessThanEquals:
} return (bA == bB || bA < bB); break;
} case EOnlineComparisonOpRedux::GreaterThan:
case EOnlineKeyValuePairDataType::Int64: return bA > bB; break;
{ case EOnlineComparisonOpRedux::LessThan:
uint64 bA, bB; return bA < bB; break;
A.GetValue(bA); default:
B.GetValue(bB); return false; break;
switch (Comparator) }
{ }
case EOnlineComparisonOpRedux::Equals: case EOnlineKeyValuePairDataType::Int32:
return bA == bB; break; {
case EOnlineComparisonOpRedux::NotEquals: int32 bA, bB;
return bA != bB; break; A.GetValue(bA);
case EOnlineComparisonOpRedux::GreaterThanEquals: B.GetValue(bB);
return (bA == bB || bA > bB); break; switch (Comparator)
case EOnlineComparisonOpRedux::LessThanEquals: {
return (bA == bB || bA < bB); break; case EOnlineComparisonOpRedux::Equals:
case EOnlineComparisonOpRedux::GreaterThan: return bA == bB; break;
return bA > bB; break; case EOnlineComparisonOpRedux::NotEquals:
case EOnlineComparisonOpRedux::LessThan: return bA != bB; break;
return bA < bB; break; case EOnlineComparisonOpRedux::GreaterThanEquals:
default: return (bA == bB || bA > bB); break;
return false; break; case EOnlineComparisonOpRedux::LessThanEquals:
} return (bA == bB || bA < bB); break;
} case EOnlineComparisonOpRedux::GreaterThan:
return bA > bB; break;
case EOnlineKeyValuePairDataType::String: case EOnlineComparisonOpRedux::LessThan:
{ return bA < bB; break;
FString bA, bB; default:
A.GetValue(bA); return false; break;
B.GetValue(bB); }
switch (Comparator) }
{ case EOnlineKeyValuePairDataType::Int64:
case EOnlineComparisonOpRedux::Equals: {
return bA == bB; break; uint64 bA, bB;
case EOnlineComparisonOpRedux::NotEquals: A.GetValue(bA);
return bA != bB; break; B.GetValue(bB);
default: switch (Comparator)
return false; break; {
} case EOnlineComparisonOpRedux::Equals:
} return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals:
case EOnlineKeyValuePairDataType::Empty: return bA != bB; break;
case EOnlineKeyValuePairDataType::Blob: case EOnlineComparisonOpRedux::GreaterThanEquals:
default: return (bA == bB || bA > bB); break;
return false; break; case EOnlineComparisonOpRedux::LessThanEquals:
} return (bA == bB || bA < bB); break;
case EOnlineComparisonOpRedux::GreaterThan:
return bA > bB; break;
case EOnlineComparisonOpRedux::LessThan:
return bA < bB; break;
default:
return false; break;
}
}
case EOnlineKeyValuePairDataType::String:
{
FString bA, bB;
A.GetValue(bA);
B.GetValue(bB);
switch (Comparator)
{
case EOnlineComparisonOpRedux::Equals:
return bA == bB; break;
case EOnlineComparisonOpRedux::NotEquals:
return bA != bB; break;
default:
return false; break;
}
}
case EOnlineKeyValuePairDataType::Empty:
case EOnlineKeyValuePairDataType::Blob:
default:
return false; break;
}
} }

View File

@@ -1,94 +1,112 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "GetFriendsCallbackProxy.h" #include "GetFriendsCallbackProxy.h"
#include "Online.h"
////////////////////////////////////////////////////////////////////////// #include "Interfaces/OnlineFriendsInterface.h"
// UGetFriendsCallbackProxy #include "Interfaces/OnlinePresenceInterface.h"
DEFINE_LOG_CATEGORY(AdvancedGetFriendsLog);
//////////////////////////////////////////////////////////////////////////
UGetFriendsCallbackProxy::UGetFriendsCallbackProxy(const FObjectInitializer& ObjectInitializer) // UGetFriendsCallbackProxy
: Super(ObjectInitializer) DEFINE_LOG_CATEGORY(AdvancedGetFriendsLog);
, FriendListReadCompleteDelegate(FOnReadFriendsListComplete::CreateUObject(this, &ThisClass::OnReadFriendsListCompleted))
{ UGetFriendsCallbackProxy::UGetFriendsCallbackProxy(const FObjectInitializer& ObjectInitializer)
} : Super(ObjectInitializer)
, FriendListReadCompleteDelegate(FOnReadFriendsListComplete::CreateUObject(this, &ThisClass::OnReadFriendsListCompleted))
UGetFriendsCallbackProxy* UGetFriendsCallbackProxy::GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController) {
{ }
UGetFriendsCallbackProxy* Proxy = NewObject<UGetFriendsCallbackProxy>();
Proxy->PlayerControllerWeakPtr = PlayerController; UGetFriendsCallbackProxy* UGetFriendsCallbackProxy::GetAndStoreFriendsList(UObject* WorldContextObject, class APlayerController* PlayerController)
Proxy->WorldContextObject = WorldContextObject; {
return Proxy; UGetFriendsCallbackProxy* Proxy = NewObject<UGetFriendsCallbackProxy>();
} Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->WorldContextObject = WorldContextObject;
void UGetFriendsCallbackProxy::Activate() return Proxy;
{ }
if (!PlayerControllerWeakPtr.IsValid())
{ void UGetFriendsCallbackProxy::Activate()
// Fail immediately {
UE_LOG(AdvancedGetFriendsLog, Warning, TEXT("GetFriends Failed received a bad player controller!")); if (!PlayerControllerWeakPtr.IsValid())
TArray<FBPFriendInfo> EmptyArray; {
OnFailure.Broadcast(EmptyArray); // Fail immediately
return; UE_LOG(AdvancedGetFriendsLog, Warning, TEXT("GetFriends Failed received a bad player controller!"));
} TArray<FBPFriendInfo> EmptyArray;
OnFailure.Broadcast(EmptyArray);
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); return;
if (Friends.IsValid()) }
{
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("GetFriends"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
Friends->ReadFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendListReadCompleteDelegate);
return; if (Helper.IsValid())
} {
IOnlineFriendsPtr Friends = Helper.OnlineSub->GetFriendsInterface();
// Fail immediately if (Friends.IsValid())
TArray<FBPFriendInfo> EmptyArray; {
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
OnFailure.Broadcast(EmptyArray);
} Friends->ReadFriendsList(Player->GetControllerId(), EFriendsLists::ToString((EFriendsLists::Default)), FriendListReadCompleteDelegate);
return;
void UGetFriendsCallbackProxy::OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString) }
{ }
if (bWasSuccessful)
{ // Fail immediately
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); TArray<FBPFriendInfo> EmptyArray;
if (Friends.IsValid()) OnFailure.Broadcast(EmptyArray);
{ }
// Not actually needed anymore, plus was not being validated and causing a crash
//ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); void UGetFriendsCallbackProxy::OnReadFriendsListCompleted(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorString)
{
TArray<FBPFriendInfo> FriendsListOut; if (bWasSuccessful)
TArray< TSharedRef<FOnlineFriend> > FriendList; {
Friends->GetFriendsList(LocalUserNum, ListName, FriendList); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("GetFriends"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
Helper.QueryIDFromPlayerController(PlayerControllerWeakPtr.Get());
for (int32 i = 0; i < FriendList.Num(); i++)
{ if (!Helper.IsValid())
TSharedRef<FOnlineFriend> Friend = FriendList[i]; {
FBPFriendInfo BPF; TArray<FBPFriendInfo> EmptyArray;
FOnlineUserPresence pres = Friend->GetPresence(); OnFailure.Broadcast(EmptyArray);
BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); return;
BPF.DisplayName = Friend->GetDisplayName(); }
BPF.RealName = Friend->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId()); auto Friends = Helper.OnlineSub->GetFriendsInterface();
BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame; if (Friends.IsValid())
{
BPF.PresenceInfo.bIsOnline = pres.bIsOnline; // Not actually needed anymore, plus was not being validated and causing a crash
BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport; //ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State)); TArray<FBPFriendInfo> FriendsListOut;
BPF.PresenceInfo.StatusString = pres.Status.StatusStr; TArray< TSharedRef<FOnlineFriend> > FriendList;
BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable; Friends->GetFriendsList(LocalUserNum, ListName, FriendList);
BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
for (int32 i = 0; i < FriendList.Num(); i++)
{
FriendsListOut.Add(BPF); TSharedRef<FOnlineFriend> Friend = FriendList[i];
} FBPFriendInfo BPF;
FOnlineUserPresence pres = Friend->GetPresence();
OnSuccess.Broadcast(FriendsListOut); BPF.OnlineState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
} BPF.DisplayName = Friend->GetDisplayName();
} BPF.RealName = Friend->GetRealName();
else BPF.UniqueNetId.SetUniqueNetId(Friend->GetUserId());
{ BPF.bIsPlayingSameGame = pres.bIsPlayingThisGame;
TArray<FBPFriendInfo> EmptyArray;
OnFailure.Broadcast(EmptyArray); BPF.PresenceInfo.bIsOnline = pres.bIsOnline;
} BPF.PresenceInfo.bHasVoiceSupport = pres.bHasVoiceSupport;
} BPF.PresenceInfo.bIsPlaying = pres.bIsPlaying;
BPF.PresenceInfo.PresenceState = ((EBPOnlinePresenceState)((int32)pres.Status.State));
BPF.PresenceInfo.StatusString = pres.Status.StatusStr;
BPF.PresenceInfo.bIsJoinable = pres.bIsJoinable;
BPF.PresenceInfo.bIsPlayingThisGame = pres.bIsPlayingThisGame;
FriendsListOut.Add(BPF);
}
OnSuccess.Broadcast(FriendsListOut);
}
}
else
{
TArray<FBPFriendInfo> EmptyArray;
OnFailure.Broadcast(EmptyArray);
}
}

View File

@@ -1,85 +1,104 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "GetRecentPlayersCallbackProxy.h" #include "GetRecentPlayersCallbackProxy.h"
#include "Online.h"
//////////////////////////////////////////////////////////////////////////
// UGetRecentPlayersCallbackProxy //////////////////////////////////////////////////////////////////////////
DEFINE_LOG_CATEGORY(AdvancedGetRecentPlayersLog); // UGetRecentPlayersCallbackProxy
DEFINE_LOG_CATEGORY(AdvancedGetRecentPlayersLog);
UGetRecentPlayersCallbackProxy::UGetRecentPlayersCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) UGetRecentPlayersCallbackProxy::UGetRecentPlayersCallbackProxy(const FObjectInitializer& ObjectInitializer)
, QueryRecentPlayersCompleteDelegate(FOnQueryRecentPlayersCompleteDelegate::CreateUObject(this, &ThisClass::OnQueryRecentPlayersCompleted)) : Super(ObjectInitializer)
{ , QueryRecentPlayersCompleteDelegate(FOnQueryRecentPlayersCompleteDelegate::CreateUObject(this, &ThisClass::OnQueryRecentPlayersCompleted))
} {
}
UGetRecentPlayersCallbackProxy* UGetRecentPlayersCallbackProxy::GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
{ UGetRecentPlayersCallbackProxy* UGetRecentPlayersCallbackProxy::GetAndStoreRecentPlayersList(UObject* WorldContextObject, const FBPUniqueNetId& UniqueNetId)
UGetRecentPlayersCallbackProxy* Proxy = NewObject<UGetRecentPlayersCallbackProxy>(); {
Proxy->cUniqueNetId = UniqueNetId; UGetRecentPlayersCallbackProxy* Proxy = NewObject<UGetRecentPlayersCallbackProxy>();
Proxy->WorldContextObject = WorldContextObject; Proxy->cUniqueNetId = UniqueNetId;
return Proxy; Proxy->WorldContextObject = WorldContextObject;
} return Proxy;
}
void UGetRecentPlayersCallbackProxy::Activate()
{ void UGetRecentPlayersCallbackProxy::Activate()
if (!cUniqueNetId.IsValid()) {
{ if (!cUniqueNetId.IsValid())
// Fail immediately {
UE_LOG(AdvancedGetRecentPlayersLog, Warning, TEXT("GetRecentPlayers Failed received a bad UniqueNetId!")); // Fail immediately
TArray<FBPOnlineRecentPlayer> EmptyArray; UE_LOG(AdvancedGetRecentPlayersLog, Warning, TEXT("GetRecentPlayers Failed received a bad UniqueNetId!"));
OnFailure.Broadcast(EmptyArray); TArray<FBPOnlineRecentPlayer> EmptyArray;
return; OnFailure.Broadcast(EmptyArray);
} return;
}
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("GetRecentPlayers"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
{
DelegateHandle = Friends->AddOnQueryRecentPlayersCompleteDelegate_Handle(QueryRecentPlayersCompleteDelegate); if (!Helper.OnlineSub)
{
// Testing with null namespace TArray<FBPOnlineRecentPlayer> EmptyArray;
Friends->QueryRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), ""); OnFailure.Broadcast(EmptyArray);
return; return;
} }
// Fail immediately
TArray<FBPOnlineRecentPlayer> EmptyArray; IOnlineFriendsPtr Friends = Helper.OnlineSub->GetFriendsInterface();
OnFailure.Broadcast(EmptyArray); if (Friends.IsValid())
} {
DelegateHandle = Friends->AddOnQueryRecentPlayersCompleteDelegate_Handle(QueryRecentPlayersCompleteDelegate);
void UGetRecentPlayersCallbackProxy::OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString)
{ // Testing with null namespace
Friends->QueryRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "");
IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); return;
if (Friends.IsValid()) }
Friends->ClearOnQueryRecentPlayersCompleteDelegate_Handle(DelegateHandle); // Fail immediately
TArray<FBPOnlineRecentPlayer> EmptyArray;
OnFailure.Broadcast(EmptyArray);
if (bWasSuccessful) }
{
// WHOOPS void UGetRecentPlayersCallbackProxy::OnQueryRecentPlayersCompleted(const FUniqueNetId &UserID, const FString &Namespace, bool bWasSuccessful, const FString& ErrorString)
//IOnlineFriendsPtr Friends = Online::GetFriendsInterface(); {
if (Friends.IsValid())
{ FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("GetRecentPlayers"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
TArray<FBPOnlineRecentPlayer> PlayersListOut;
TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList; if (!Helper.OnlineSub)
{
Friends->GetRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "", PlayerList); TArray<FBPOnlineRecentPlayer> EmptyArray;
OnFailure.Broadcast(EmptyArray);
for (int32 i = 0; i < PlayerList.Num(); i++) return;
{ }
TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i];
FBPOnlineRecentPlayer BPF; IOnlineFriendsPtr Friends = Helper.OnlineSub->GetFriendsInterface();
BPF.DisplayName = Player->GetDisplayName(); if (Friends.IsValid())
BPF.RealName = Player->GetRealName(); Friends->ClearOnQueryRecentPlayersCompleteDelegate_Handle(DelegateHandle);
BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId());
PlayersListOut.Add(BPF);
} if (bWasSuccessful)
{
OnSuccess.Broadcast(PlayersListOut); // WHOOPS
} //IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
} if (Friends.IsValid())
else {
{ TArray<FBPOnlineRecentPlayer> PlayersListOut;
TArray<FBPOnlineRecentPlayer> EmptyArray; TArray< TSharedRef<FOnlineRecentPlayer> > PlayerList;
OnFailure.Broadcast(EmptyArray);
} Friends->GetRecentPlayers(*(cUniqueNetId.GetUniqueNetId()), "", PlayerList);
}
for (int32 i = 0; i < PlayerList.Num(); i++)
{
TSharedRef<FOnlineRecentPlayer> Player = PlayerList[i];
FBPOnlineRecentPlayer BPF;
BPF.DisplayName = Player->GetDisplayName();
BPF.RealName = Player->GetRealName();
BPF.UniqueNetId.SetUniqueNetId(Player->GetUserId());
PlayersListOut.Add(BPF);
}
OnSuccess.Broadcast(PlayersListOut);
}
}
else
{
TArray<FBPOnlineRecentPlayer> EmptyArray;
OnFailure.Broadcast(EmptyArray);
}
}

View File

@@ -2,6 +2,7 @@
#include "GetUserPrivilegeCallbackProxy.h" #include "GetUserPrivilegeCallbackProxy.h"
#include "Online.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UGetUserPrivilegeCallbackProxy // UGetUserPrivilegeCallbackProxy
@@ -22,7 +23,14 @@ UGetUserPrivilegeCallbackProxy* UGetUserPrivilegeCallbackProxy::GetUserPrivilege
void UGetUserPrivilegeCallbackProxy::Activate() void UGetUserPrivilegeCallbackProxy::Activate()
{ {
auto Identity = Online::GetIdentityInterface(); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("GetUserPrivilege"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (!Helper.OnlineSub)
{
OnFailure.Broadcast();
return;
}
auto Identity = Helper.OnlineSub->GetIdentityInterface();
if (Identity.IsValid()) if (Identity.IsValid())
{ {

View File

@@ -2,6 +2,7 @@
#include "LoginUserCallbackProxy.h" #include "LoginUserCallbackProxy.h"
#include "Online.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// ULoginUserCallbackProxy // ULoginUserCallbackProxy
@@ -12,12 +13,13 @@ ULoginUserCallbackProxy::ULoginUserCallbackProxy(const FObjectInitializer& Objec
{ {
} }
ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken) ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString AuthType)
{ {
ULoginUserCallbackProxy* Proxy = NewObject<ULoginUserCallbackProxy>(); ULoginUserCallbackProxy* Proxy = NewObject<ULoginUserCallbackProxy>();
Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->UserID = UserID; Proxy->UserID = UserID;
Proxy->UserToken = UserToken; Proxy->UserToken = UserToken;
Proxy->AuthType = AuthType;
Proxy->WorldContextObject = WorldContextObject; Proxy->WorldContextObject = WorldContextObject;
return Proxy; return Proxy;
} }
@@ -39,12 +41,24 @@ void ULoginUserCallbackProxy::Activate()
return; return;
} }
auto Identity = Online::GetIdentityInterface(); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("LoginUser"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (!Helper.OnlineSub)
{
OnFailure.Broadcast();
return;
}
auto Identity = Helper.OnlineSub->GetIdentityInterface();
if (Identity.IsValid()) if (Identity.IsValid())
{ {
// Fallback to default AuthType if nothing is specified
if (AuthType.IsEmpty())
{
AuthType = Identity->GetAuthType();
}
DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate); DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate);
FOnlineAccountCredentials AccountCreds(Identity->GetAuthType(), UserID, UserToken); FOnlineAccountCredentials AccountCreds(AuthType, UserID, UserToken);
Identity->Login(Player->GetControllerId(), AccountCreds); Identity->Login(Player->GetControllerId(), AccountCreds);
return; return;
} }
@@ -59,14 +73,30 @@ void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessfu
{ {
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
FUniqueNetIdRepl UniqueID(UserId.AsShared());
if (Player) if (Player)
{ {
auto Identity = Online::GetIdentityInterface(); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("GetUserPrivilege"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (!Helper.OnlineSub)
{
OnFailure.Broadcast();
return;
}
auto Identity = Helper.OnlineSub->GetIdentityInterface();
if (Identity.IsValid()) if (Identity.IsValid())
{ {
Identity->ClearOnLoginCompleteDelegate_Handle(Player->GetControllerId(), DelegateHandle); Identity->ClearOnLoginCompleteDelegate_Handle(Player->GetControllerId(), DelegateHandle);
} }
Player->SetCachedUniqueNetId(UniqueID);
}
if (APlayerState* State = PlayerControllerWeakPtr->PlayerState)
{
// Update UniqueId. See also ShowLoginUICallbackProxy.cpp
State->SetUniqueId(UniqueID);
} }
} }

View File

@@ -2,6 +2,7 @@
#include "LogoutUserCallbackProxy.h" #include "LogoutUserCallbackProxy.h"
#include "Online.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// ULogoutUserCallbackProxy // ULogoutUserCallbackProxy
@@ -29,7 +30,6 @@ void ULogoutUserCallbackProxy::Activate()
return; return;
} }
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
if (!Player) if (!Player)
@@ -38,7 +38,14 @@ void ULogoutUserCallbackProxy::Activate()
return; return;
} }
auto Identity = Online::GetIdentityInterface(); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("LogoutUser"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (!Helper.OnlineSub)
{
OnFailure.Broadcast();
return;
}
auto Identity = Helper.OnlineSub->GetIdentityInterface();
if (Identity.IsValid()) if (Identity.IsValid())
{ {
@@ -60,7 +67,14 @@ void ULogoutUserCallbackProxy::OnCompleted(int LocalUserNum, bool bWasSuccessful
if (Player) if (Player)
{ {
auto Identity = Online::GetIdentityInterface(); FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("LogoutUser"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (!Helper.OnlineSub)
{
OnFailure.Broadcast();
return;
}
auto Identity = Helper.OnlineSub->GetIdentityInterface();
if (Identity.IsValid()) if (Identity.IsValid())
{ {

View File

@@ -1,73 +1,82 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "SendFriendInviteCallbackProxy.h" #include "SendFriendInviteCallbackProxy.h"
#include "Online.h"
//////////////////////////////////////////////////////////////////////////
// UGetRecentPlayersCallbackProxy //////////////////////////////////////////////////////////////////////////
DEFINE_LOG_CATEGORY(AdvancedSendFriendInviteLog); // UGetRecentPlayersCallbackProxy
DEFINE_LOG_CATEGORY(AdvancedSendFriendInviteLog);
USendFriendInviteCallbackProxy::USendFriendInviteCallbackProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer) USendFriendInviteCallbackProxy::USendFriendInviteCallbackProxy(const FObjectInitializer& ObjectInitializer)
, OnSendInviteCompleteDelegate(FOnSendInviteComplete::CreateUObject(this, &ThisClass::OnSendInviteComplete)) : Super(ObjectInitializer)
{ , OnSendInviteCompleteDelegate(FOnSendInviteComplete::CreateUObject(this, &ThisClass::OnSendInviteComplete))
} {
}
USendFriendInviteCallbackProxy* USendFriendInviteCallbackProxy::SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited)
{ USendFriendInviteCallbackProxy* USendFriendInviteCallbackProxy::SendFriendInvite(UObject* WorldContextObject, APlayerController *PlayerController, const FBPUniqueNetId &UniqueNetIDInvited)
USendFriendInviteCallbackProxy* Proxy = NewObject<USendFriendInviteCallbackProxy>(); {
Proxy->PlayerControllerWeakPtr = PlayerController; USendFriendInviteCallbackProxy* Proxy = NewObject<USendFriendInviteCallbackProxy>();
Proxy->cUniqueNetId = UniqueNetIDInvited; Proxy->PlayerControllerWeakPtr = PlayerController;
Proxy->WorldContextObject = WorldContextObject; Proxy->cUniqueNetId = UniqueNetIDInvited;
return Proxy; Proxy->WorldContextObject = WorldContextObject;
} return Proxy;
}
void USendFriendInviteCallbackProxy::Activate()
{ void USendFriendInviteCallbackProxy::Activate()
if (!cUniqueNetId.IsValid()) {
{ if (!cUniqueNetId.IsValid())
// Fail immediately {
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad UniqueNetId!")); // Fail immediately
OnFailure.Broadcast(); UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad UniqueNetId!"));
return; OnFailure.Broadcast();
} return;
}
if (!PlayerControllerWeakPtr.IsValid())
{ if (!PlayerControllerWeakPtr.IsValid())
// Fail immediately {
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad playercontroller!")); // Fail immediately
OnFailure.Broadcast(); UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed received a bad playercontroller!"));
return; OnFailure.Broadcast();
} return;
}
IOnlineFriendsPtr Friends = Online::GetFriendsInterface();
if (Friends.IsValid()) FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("SendFriendInvite"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
{
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player); if (!Helper.OnlineSub)
{
if (!Player) OnFailure.Broadcast();
{ return;
// Fail immediately }
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed couldn't cast to ULocalPlayer!"));
OnFailure.Broadcast(); auto Friends = Helper.OnlineSub->GetFriendsInterface();
return; if (Friends.IsValid())
} {
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
Friends->SendInvite(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString((EFriendsLists::Default)), OnSendInviteCompleteDelegate);
return; if (!Player)
} {
// Fail immediately // Fail immediately
OnFailure.Broadcast(); UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed couldn't cast to ULocalPlayer!"));
} OnFailure.Broadcast();
return;
void USendFriendInviteCallbackProxy::OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString) }
{
if ( bWasSuccessful ) Friends->SendInvite(Player->GetControllerId(), *cUniqueNetId.GetUniqueNetId(), EFriendsLists::ToString((EFriendsLists::Default)), OnSendInviteCompleteDelegate);
{ return;
OnSuccess.Broadcast(); }
} // Fail immediately
else OnFailure.Broadcast();
{ }
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed with error: %s"), *ErrorString);
OnFailure.Broadcast(); void USendFriendInviteCallbackProxy::OnSendInviteComplete(int32 LocalPlayerNum, bool bWasSuccessful, const FUniqueNetId &InvitedPlayer, const FString &ListName, const FString &ErrorString)
} {
} if ( bWasSuccessful )
{
OnSuccess.Broadcast();
}
else
{
UE_LOG(AdvancedSendFriendInviteLog, Warning, TEXT("SendFriendInvite Failed with error: %s"), *ErrorString);
OnFailure.Broadcast();
}
}

View File

@@ -0,0 +1,58 @@
#include "StartSessionCallbackProxyAdvanced.h"
UStartSessionCallbackProxyAdvanced::UStartSessionCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, StartCompleteDelegate(FOnStartSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnStartCompleted))
{
}
UStartSessionCallbackProxyAdvanced* UStartSessionCallbackProxyAdvanced::StartAdvancedSession(
UObject* WorldContextObject)
{
UStartSessionCallbackProxyAdvanced* Proxy = NewObject<UStartSessionCallbackProxyAdvanced>();
Proxy->WorldContextObject = WorldContextObject;
return Proxy;
}
void UStartSessionCallbackProxyAdvanced::Activate()
{
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("StartSession"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (Helper.OnlineSub != nullptr)
{
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (Sessions.IsValid())
{
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
Sessions->StartSession(NAME_GameSession);
return;
}
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
}
// Fail immediately
OnFailure.Broadcast();
}
void UStartSessionCallbackProxyAdvanced::OnStartCompleted(FName SessionName, bool bWasSuccessful)
{
FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("StartSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (Helper.OnlineSub != nullptr)
{
auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (Sessions.IsValid())
{
Sessions->ClearOnStartSessionCompleteDelegate_Handle(StartCompleteDelegateHandle);
}
}
if (bWasSuccessful)
{
OnSuccess.Broadcast();
}
else
{
OnFailure.Broadcast();
}
}

View File

@@ -12,7 +12,7 @@ UUpdateSessionCallbackProxyAdvanced::UUpdateSessionCallbackProxyAdvanced(const F
{ {
} }
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer) UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer, bool bShouldAdvertise)
{ {
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>(); UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
Proxy->NumPublicConnections = PublicConnections; Proxy->NumPublicConnections = PublicConnections;
@@ -24,75 +24,79 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update
Proxy->bRefreshOnlineData = bRefreshOnlineData; Proxy->bRefreshOnlineData = bRefreshOnlineData;
Proxy->bAllowJoinInProgress = bAllowJoinInProgress; Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
Proxy->bDedicatedServer = bIsDedicatedServer; Proxy->bDedicatedServer = bIsDedicatedServer;
Proxy->bShouldAdvertise = bShouldAdvertise;
return Proxy; return Proxy;
} }
void UUpdateSessionCallbackProxyAdvanced::Activate() void UUpdateSessionCallbackProxyAdvanced::Activate()
{ {
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSession"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
IOnlineSessionPtr Sessions = Online::GetSessionInterface(); if (Helper.OnlineSub != nullptr)
if (Sessions.IsValid())
{ {
if (Sessions->GetNumSessions() < 1) const auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (Sessions.IsValid())
{ {
OnFailure.Broadcast(); if (Sessions->GetNumSessions() < 1)
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!")); {
OnFailure.Broadcast();
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!"));
return;
}
// This gets the actual session itself
//FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession);
FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession);
if (!Settings)
{
// Fail immediately
OnFailure.Broadcast();
return;
}
OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate);
// FOnlineSessionSettings Settings;
//Settings->BuildUniqueId = GetBuildUniqueId();
Settings->NumPublicConnections = NumPublicConnections;
Settings->NumPrivateConnections = NumPrivateConnections;
Settings->bShouldAdvertise = bShouldAdvertise;
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
Settings->bIsLANMatch = bUseLAN;
//Settings->bUsesPresence = true;
//Settings->bAllowJoinViaPresence = true;
Settings->bAllowInvites = bAllowInvites;
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
Settings->bIsDedicated = bDedicatedServer;
FOnlineSessionSetting * fSetting = NULL;
FOnlineSessionSetting ExtraSetting;
for (int i = 0; i < ExtraSettings.Num(); i++)
{
fSetting = Settings->Settings.Find(ExtraSettings[i].Key);
if (fSetting)
{
fSetting->Data = ExtraSettings[i].Data;
}
else
{
ExtraSetting.Data = ExtraSettings[i].Data;
ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService;
Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting);
}
}
Sessions->UpdateSession(NAME_GameSession, *Settings, bRefreshOnlineData);
// OnUpdateCompleted will get called, nothing more to do now
return; return;
} }
else
// This gets the actual session itself
//FNamedOnlineSession * curSession = Sessions->GetNamedSession(GameSessionName);
FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(GameSessionName);
if (!Settings)
{ {
// Fail immediately FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
OnFailure.Broadcast();
return;
} }
OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate);
// FOnlineSessionSettings Settings;
//Settings->BuildUniqueId = GetBuildUniqueId();
Settings->NumPublicConnections = NumPublicConnections;
Settings->NumPrivateConnections = NumPrivateConnections;
//Settings->bShouldAdvertise = true;
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
Settings->bIsLANMatch = bUseLAN;
//Settings->bUsesPresence = true;
//Settings->bAllowJoinViaPresence = true;
Settings->bAllowInvites = bAllowInvites;
Settings->bAllowJoinInProgress = bAllowJoinInProgress;
Settings->bIsDedicated = bDedicatedServer;
FOnlineSessionSetting * fSetting = NULL;
FOnlineSessionSetting ExtraSetting;
for (int i = 0; i < ExtraSettings.Num(); i++)
{
fSetting = Settings->Settings.Find(ExtraSettings[i].Key);
if (fSetting)
{
fSetting->Data = ExtraSettings[i].Data;
}
else
{
ExtraSetting.Data = ExtraSettings[i].Data;
ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService;
Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting);
}
}
Sessions->UpdateSession(GameSessionName, *Settings, bRefreshOnlineData);
// OnUpdateCompleted will get called, nothing more to do now
return;
}
else
{
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
} }
// Fail immediately // Fail immediately
OnFailure.Broadcast(); OnFailure.Broadcast();
@@ -101,15 +105,20 @@ void UUpdateSessionCallbackProxyAdvanced::Activate()
void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful) void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful)
{ {
IOnlineSessionPtr Sessions = Online::GetSessionInterface(); const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject.Get(), EGetWorldErrorMode::LogAndReturnNull));
if (Sessions.IsValid())
if (Helper.OnlineSub != nullptr)
{ {
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle); const auto Sessions = Helper.OnlineSub->GetSessionInterface();
if (Sessions.IsValid())
if (bWasSuccessful)
{ {
OnSuccess.Broadcast(); Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
return;
if (bWasSuccessful)
{
OnSuccess.Broadcast();
return;
}
} }
} }

View File

@@ -1,20 +1,38 @@
{ {
"FileVersion" : 3, "FileVersion" : 3,
"FriendlyName" : "Advanced Steam Sessions", "FriendlyName" : "Advanced Steam Sessions",
"Version" : 1.9, "Version" : 5.1,
"VersionName": "1.9", "VersionName": "5.1",
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS", "Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
"Category" : "Advanced Sessions Plugin", "Category" : "Advanced Sessions Plugin",
"CreatedBy" : "Joshua Statzer", "CreatedBy" : "Joshua Statzer",
"CreatedByURL" : "N/A", "CreatedByURL" : "N/A",
"Modules" : "Modules" :
[ [
{ {
"Name" : "AdvancedSteamSessions", "Name": "AdvancedSteamSessions",
"Type" : "RunTime", "Type": "RunTime",
"LoadingPhase" : "PreDefault" "LoadingPhase": "Default"
} }
] ],
"Plugins": [
{
"Name": "AdvancedSessions",
"Enabled": true
},
{
"Name": "OnlineSubsystem",
"Enabled": true
},
{
"Name": "OnlineSubsystemUtils",
"Enabled": true
},
{
"Name": "SteamShared",
"Enabled": true
}
]
} }

View File

@@ -0,0 +1,8 @@
[FilterPlugin]
; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and
; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively.
;
; Examples:
; /README.txt
; /Extras/...
; /Binaries/ThirdParty/*.dll

View File

@@ -1,22 +1,22 @@
using UnrealBuildTool; using UnrealBuildTool;
using System.IO; using System.IO;
public class AdvancedSteamSessions : ModuleRules public class AdvancedSteamSessions : ModuleRules
{ {
public AdvancedSteamSessions(ReadOnlyTargetRules Target) : base(Target) public AdvancedSteamSessions(ReadOnlyTargetRules Target) : base(Target)
{ {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
//bEnforceIWYU = true; //bEnforceIWYU = true;
Definitions.Add("WITH_ADVANCED_STEAM_SESSIONS=1"); PublicDefinitions.Add("WITH_ADVANCED_STEAM_SESSIONS=1");
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets", "AdvancedSessions"/*"Voice", "OnlineSubsystemSteam"*/ }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets", "AdvancedSessions"/*"Voice", "OnlineSubsystemSteam"*/ });
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/}); PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/});
if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac)) if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Linux) || (Target.Platform == UnrealTargetPlatform.Mac))
{ {
PublicDependencyModuleNames.AddRange(new string[] { "Steamworks",/*"Voice",*/ "OnlineSubsystemSteam" }); PublicDependencyModuleNames.AddRange(new string[] { "SteamShared", "Steamworks"/*, "OnlineSubsystemSteam"*/ });
PublicIncludePaths.AddRange(new string[] { "../Plugins/Online/OnlineSubsystemSteam/Source/Private" });// This is dumb but it isn't very open //PublicIncludePaths.AddRange(new string[] { "../Plugins/Online/OnlineSubsystemSteam/Source/Private" });// This is dumb but it isn't very open
} }
} }
} }

View File

@@ -1,93 +1,389 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineFriendsInterface.h" #include "Interfaces/OnlineFriendsInterface.h"
#include "OnlineUserInterface.h" #include "Interfaces/OnlineUserInterface.h"
#include "OnlineMessageInterface.h" #include "Interfaces/OnlineMessageInterface.h"
#include "OnlinePresenceInterface.h" #include "Interfaces/OnlinePresenceInterface.h"
#include "Engine/GameInstance.h" #include "Engine/GameInstance.h"
#include "OnlineSessionInterface.h" #include "Interfaces/OnlineSessionInterface.h"
#include "BlueprintDataDefinitions.h"
#include "UObjectIterator.h" #include "UObject/UObjectIterator.h"
#include "AdvancedSteamFriendsLibrary.generated.h" // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK
//General Advanced Sessions Log #ifdef _MSC_VER
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamFriendsLog, Log, All); #pragma warning(push)
#pragma warning(disable:4996)
UENUM(Blueprintable) // #TODO check back on this at some point
enum class SteamAvatarSize : uint8 #pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
{ #endif
SteamAvatar_Small = 1,
SteamAvatar_Medium = 2, #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
SteamAvatar_Large = 3
}; #pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT
USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups")
struct FBPSteamGroupInfo #if USING_CODE_ANALYSIS
{ MSVC_PRAGMA(warning(push))
GENERATED_USTRUCT_BODY() MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#endif // USING_CODE_ANALYSIS
public:
#include <steam/steam_api.h>
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FBPUniqueNetId GroupID; // Uint64 representation #if USING_CODE_ANALYSIS
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") MSVC_PRAGMA(warning(pop))
FString GroupName; #endif // USING_CODE_ANALYSIS
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FString GroupTag; #include <steam/isteamapps.h>
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") #include <steam/isteamapplist.h>
int32 numOnline; //#include <OnlineSubsystemSteamTypes.h>
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") #pragma pop_macro("ARRAY_COUNT")
int32 numInGame;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") // @todo Steam: See above
int32 numChatting; #ifdef _MSC_VER
#pragma warning(pop)
}; #endif
// Making a copy of this here since the original is still in a private folder and is screwing with things
/**
UCLASS() * Steam specific implementation of the unique net id
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary */
{ class FUniqueNetIdSteam2 :
GENERATED_BODY() public FUniqueNetId
public: {
PACKAGE_SCOPE:
//********* Friend List Functions *************// /** Holds the net id for a player */
uint64 UniqueNetId;
// Get a texture of a valid friends avatar, STEAM ONLY, Returns invalid texture if the subsystem hasn't loaded that size of avatar yet
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result")) /** Hidden on purpose */
static UTexture2D * GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize = SteamAvatarSize::SteamAvatar_Medium); FUniqueNetIdSteam2() :
UniqueNetId(0)
// Preloads the avatar and name of a steam friend, return whether it is already available or not, STEAM ONLY, Takes time to actually load everything after this is called. {
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") }
static bool RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly = false);
/**
// Gets the level of a friends steam account, STEAM ONLY, Returns -1 if the steam level is not known, might need RequestSteamFriendInfo called first. * Copy Constructor
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") *
static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId); * @param Src the id to copy
*/
// Gets the persona name of a steam ID, STEAM ONLY, Returns empty if no result, might need RequestSteamFriendInfo called first. explicit FUniqueNetIdSteam2(const FUniqueNetIdSteam2& Src) :
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") UniqueNetId(Src.UniqueNetId)
static FString GetSteamPersonaName(const FBPUniqueNetId UniqueNetId); {
}
// Creates a unique steam id directly from a string holding a uint64 value, useful for testing
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") public:
static FBPUniqueNetId CreateSteamIDFromString(const FString SteamID64); /**
* Constructs this object with the specified net id
/* Gets the current game played by a friend - AppID is int32 even though steam ids are uint32, can't be helped in blueprint currently *
* The game name is retrieved from steamSDK AppList which isn't available to all game IDs without request, can use the AppID with the * @param InUniqueNetId the id to set ours to
* WebAPI GetAppList request as an alternative. */
*/ explicit FUniqueNetIdSteam2(uint64 InUniqueNetId) :
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result")) UniqueNetId(InUniqueNetId)
static void GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result, FString & GameName, int32 & AppID); {
}
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups")
static void GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups); /**
}; * Constructs this object with the steam id
*
* @param InUniqueNetId the id to set ours to
*/
explicit FUniqueNetIdSteam2(CSteamID InSteamId) :
UniqueNetId(InSteamId.ConvertToUint64())
{
}
/**
* Constructs this object with the specified net id
*
* @param String textual representation of an id
*/
explicit FUniqueNetIdSteam2(const FString& Str) :
UniqueNetId(FCString::Atoi64(*Str))
{
}
/**
* Constructs this object with the specified net id
*
* @param InUniqueNetId the id to set ours to (assumed to be FUniqueNetIdSteam in fact)
*/
explicit FUniqueNetIdSteam2(const FUniqueNetId& InUniqueNetId) :
UniqueNetId(*(uint64*)InUniqueNetId.GetBytes())
{
}
virtual FName GetType() const override
{
return STEAM_SUBSYSTEM;
}
/**
* Get the raw byte representation of this net id
* This data is platform dependent and shouldn't be manipulated directly
*
* @return byte array of size GetSize()
*/
virtual const uint8* GetBytes() const override
{
return (uint8*)&UniqueNetId;
}
/**
* Get the size of the id
*
* @return size in bytes of the id representation
*/
virtual int32 GetSize() const override
{
return sizeof(uint64);
}
/**
* Check the validity of the id
*
* @return true if this is a well formed ID, false otherwise
*/
virtual bool IsValid() const override
{
return UniqueNetId != 0 && CSteamID(UniqueNetId).IsValid();
}
/**
* Platform specific conversion to string representation of data
*
* @return data in string form
*/
virtual FString ToString() const override
{
return FString::Printf(TEXT("%llu"), UniqueNetId);
}
/**
* Get a human readable representation of the net id
* Shouldn't be used for anything other than logging/debugging
*
* @return id in string form
*/
virtual FString ToDebugString() const override
{
CSteamID SteamID(UniqueNetId);
if (SteamID.IsLobby())
{
return FString::Printf(TEXT("Lobby [0x%llX]"), UniqueNetId);
}
else if (SteamID.BAnonGameServerAccount())
{
return FString::Printf(TEXT("Server [0x%llX]"), UniqueNetId);
}
else if (SteamID.IsValid())
{
const FString NickName(SteamFriends() ? UTF8_TO_TCHAR(SteamFriends()->GetFriendPersonaName(UniqueNetId)) : TEXT("UNKNOWN"));
return FString::Printf(TEXT("%s [0x%llX]"), *NickName, UniqueNetId);
}
else
{
return FString::Printf(TEXT("INVALID [0x%llX]"), UniqueNetId);
}
}
virtual uint32 GetTypeHash() const override
{
return ::GetTypeHash(UniqueNetId);
}
/** Convenience cast to CSteamID */
operator CSteamID()
{
return UniqueNetId;
}
/** Convenience cast to CSteamID */
operator const CSteamID() const
{
return UniqueNetId;
}
/** Convenience cast to CSteamID pointer */
operator CSteamID*()
{
return (CSteamID*)&UniqueNetId;
}
/** Convenience cast to CSteamID pointer */
operator const CSteamID*() const
{
return (const CSteamID*)&UniqueNetId;
}
friend FArchive& operator<<(FArchive& Ar, FUniqueNetIdSteam2& UserId)
{
return Ar << UserId.UniqueNetId;
}
};
#endif
#include "AdvancedSteamFriendsLibrary.generated.h"
//General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamFriendsLog, Log, All);
UENUM(Blueprintable)
enum class SteamAvatarSize : uint8
{
SteamAvatar_INVALID = 0,
SteamAvatar_Small = 1,
SteamAvatar_Medium = 2,
SteamAvatar_Large = 3
};
UENUM(Blueprintable)
enum class ESteamUserOverlayType : uint8
{
/*Opens the overlay web browser to the specified user or groups profile.*/
steamid,
/*Opens a chat window to the specified user, or joins the group chat.*/
chat,
/*Opens a window to a Steam Trading session that was started with the ISteamEconomy / StartTrade Web API.*/
jointrade,
/*Opens the overlay web browser to the specified user's stats.*/
stats,
/*Opens the overlay web browser to the specified user's achievements.*/
achievements,
/*Opens the overlay in minimal mode prompting the user to add the target user as a friend.*/
friendadd,
/*Opens the overlay in minimal mode prompting the user to remove the target friend.*/
friendremove,
/*Opens the overlay in minimal mode prompting the user to accept an incoming friend invite.*/
friendrequestaccept,
/*Opens the overlay in minimal mode prompting the user to ignore an incoming friend invite.*/
friendrequestignore,
/*Opens the invite overlay, invitations sent from this dialog will be for the provided lobby*/
invitetolobby
};
static FString EnumToString(const FString& enumName, uint8 value)
{
const UEnum* EnumPtr = FindFirstObject<UEnum>(*enumName, EFindFirstObjectOptions::None, ELogVerbosity::Warning, TEXT("EumtoString"));
if (!EnumPtr)
return FString();
FString EnumName = EnumPtr->GetNameStringByIndex(value);
return EnumName;
}
USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups")
struct FBPSteamGroupInfo
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FBPUniqueNetId GroupID; // Uint64 representation
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FString GroupName;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FString GroupTag;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
int32 numOnline = 0;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
int32 numInGame = 0;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
int32 numChatting = 0;
};
UENUM(Blueprintable)
enum class EBPTextFilteringContext : uint8
{
/*Unknown context.*/
FContext_Unknown = 0,
/*Game content, only legally required filtering is performed.*/
FContext_GameContent = 1,
/*Char from another player.*/
FContext_Chat = 2,
/*Character or item name.*/
FContext_Name = 3
};
UCLASS()
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
//********* Friend List Functions *************//
// Get a texture of a valid friends avatar, STEAM ONLY, Returns invalid texture if the subsystem hasn't loaded that size of avatar yet
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result"))
static UTexture2D * GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize = SteamAvatarSize::SteamAvatar_Medium);
// Preloads the avatar and name of a steam friend, return whether it is already available or not, STEAM ONLY, Takes time to actually load everything after this is called.
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static bool RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly = false);
// Opens the steam overlay to go to the specified user dialog
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static bool OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType);
// Returns if the steam overlay is currently active (this can return false during initial overlay hooking)
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
static bool IsOverlayEnabled();
// Gets the level of a friends steam account, STEAM ONLY, Returns -1 if the steam level is not known, might need RequestSteamFriendInfo called first.
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId);
// Gets the persona name of a steam ID, STEAM ONLY, Returns empty if no result, might need RequestSteamFriendInfo called first.
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
static FString GetSteamPersonaName(const FBPUniqueNetId UniqueNetId);
// Creates a unique steam id directly from a string holding a uint64 value, useful for testing
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
static FBPUniqueNetId CreateSteamIDFromString(const FString SteamID64);
// Retreives the local steam ID from steam
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
static FBPUniqueNetId GetLocalSteamIDFromSteam();
/* Gets the current game played by a friend - AppID is int32 even though steam ids are uint32, can't be helped in blueprint currently
* can use the AppID with the WebAPI GetAppList request.
*/
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result"))
static void GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID);
// Get a full list of steam groups
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups")
static void GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups);
// Initializes text filtering (pre-loading dictonaries)
// Returns if it succeeded, false if filtering is unavailable for the games language
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering")
static bool InitTextFiltering();
// Attempts to filter a string with the given filtering context
// Returns true if the text has been filtered, false if it hasn't (no filtering required or operation failed)
// If false it will still output the original text
// Textsource is the steam id that is the source of the text (player name / chat)
// Requires that InitTextFiltering be called first!!
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering")
static bool FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText);
// Returns if steam is running in big picture mode
UFUNCTION(BlueprintPure, Category = "Online|SteamAPI")
static bool IsSteamInBigPictureMode();
};

View File

@@ -1,12 +1,12 @@
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "ModuleManager.h" #include "Modules/ModuleManager.h"
class AdvancedSteamSessions : public IModuleInterface class AdvancedSteamSessions : public IModuleInterface
{ {
public: public:
/** IModuleInterface implementation */ /** IModuleInterface implementation */
void StartupModule(); void StartupModule();
void ShutdownModule(); void ShutdownModule();
}; };

View File

@@ -1,303 +1,351 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#pragma once #pragma once
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
#include "Kismet/BlueprintFunctionLibrary.h" #include "Kismet/BlueprintFunctionLibrary.h"
#include "Online.h" #include "Online.h"
#include "OnlineSubsystem.h" #include "OnlineSubsystem.h"
#include "OnlineSessionInterface.h" #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#include "steam/isteamugc.h"
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just #include "steam/isteamremotestorage.h"
// disable the warnings locally. Remove when this is fixed in the SDK #endif
#ifdef _MSC_VER #include "Interfaces/OnlineSessionInterface.h"
#pragma warning(push)
#pragma warning(disable:4996) // @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
#endif // disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #pragma warning(push)
#pragma warning(disable:4996)
#pragma push_macro("ARRAY_COUNT") // #TODO check back on this at some point
#undef ARRAY_COUNT #pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
#endif
#include <steam/steam_api.h>
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#pragma pop_macro("ARRAY_COUNT")
#pragma push_macro("ARRAY_COUNT")
#endif #undef ARRAY_COUNT
// @todo Steam: See above #if USING_CODE_ANALYSIS
#ifdef _MSC_VER MSVC_PRAGMA(warning(push))
#pragma warning(pop) MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#endif #endif // USING_CODE_ANALYSIS
#include <steam/steam_api.h>
#include "AdvancedSteamWorkshopLibrary.generated.h"
#if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(pop))
//General Advanced Sessions Log #endif // USING_CODE_ANALYSIS
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamWorkshopLog, Log, All);
#pragma pop_macro("ARRAY_COUNT")
// Using a custom struct because uint32 isn't blueprint supported and I don't want to cast to int32
// due to the size of the workshop it could end up overflowing? #endif
USTRUCT(BlueprintType)
struct FBPSteamWorkshopID // @todo Steam: See above
{ #ifdef _MSC_VER
GENERATED_USTRUCT_BODY() #pragma warning(pop)
#endif
public:
uint64 SteamWorkshopID; #include "AdvancedSteamWorkshopLibrary.generated.h"
FBPSteamWorkshopID()
{ //General Advanced Sessions Log
DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamWorkshopLog, Log, All);
}
FBPSteamWorkshopID(uint64 ID) // Using a custom struct because uint32 isn't blueprint supported and I don't want to cast to int32
{ // due to the size of the workshop it could end up overflowing?
SteamWorkshopID = ID; USTRUCT(BlueprintType)
} struct FBPSteamWorkshopID
}; {
GENERATED_USTRUCT_BODY()
// General result codes - Copying steams version over public:
// Check these to future proof
UENUM(BlueprintType) uint64 SteamWorkshopID;
enum class FBPSteamResult : uint8
{ FBPSteamWorkshopID()
k_EResultOK = 1, // success {
k_EResultFail = 2, // generic failure
k_EResultNoConnection = 3, // no/failed network connection }
// k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
k_EResultInvalidPassword = 5, // password/ticket is invalid FBPSteamWorkshopID(uint64 ID)
k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere {
k_EResultInvalidProtocolVer = 7, // protocol version is incorrect SteamWorkshopID = ID;
k_EResultInvalidParam = 8, // a parameter is incorrect }
k_EResultFileNotFound = 9, // file was not found };
k_EResultBusy = 10, // called method busy - action not taken
k_EResultInvalidState = 11, // called object was in an invalid state
k_EResultInvalidName = 12, // name is invalid // General result codes - Copying steams version over
k_EResultInvalidEmail = 13, // email is invalid // Check these to future proof
k_EResultDuplicateName = 14, // name is not unique UENUM(BlueprintType)
k_EResultAccessDenied = 15, // access is denied enum class FBPSteamResult : uint8
k_EResultTimeout = 16, // operation timed out {
k_EResultBanned = 17, // VAC2 banned K_EResultInvalid = 0,
k_EResultAccountNotFound = 18, // account not found k_EResultOK = 1, // success
k_EResultInvalidSteamID = 19, // steamID is invalid k_EResultFail = 2, // generic failure
k_EResultServiceUnavailable = 20, // The requested service is currently unavailable k_EResultNoConnection = 3, // no/failed network connection
k_EResultNotLoggedOn = 21, // The user is not logged on // k_EResultNoConnectionRetry = 4, // OBSOLETE - removed
k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party) k_EResultInvalidPassword = 5, // password/ticket is invalid
k_EResultEncryptionFailure = 23, // Encryption or Decryption failed k_EResultLoggedInElsewhere = 6, // same user logged in elsewhere
k_EResultInsufficientPrivilege = 24, // Insufficient privilege k_EResultInvalidProtocolVer = 7, // protocol version is incorrect
k_EResultLimitExceeded = 25, // Too much of a good thing k_EResultInvalidParam = 8, // a parameter is incorrect
k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes) k_EResultFileNotFound = 9, // file was not found
k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired k_EResultBusy = 10, // called method busy - action not taken
k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again k_EResultInvalidState = 11, // called object was in an invalid state
k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time k_EResultInvalidName = 12, // name is invalid
k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user k_EResultInvalidEmail = 13, // email is invalid
k_EResultIPNotFound = 31, // IP address not found k_EResultDuplicateName = 14, // name is not unique
k_EResultPersistFailed = 32, // failed to write change to the data store k_EResultAccessDenied = 15, // access is denied
k_EResultLockingFailed = 33, // failed to acquire access lock for this operation k_EResultTimeout = 16, // operation timed out
k_EResultLogonSessionReplaced = 34, k_EResultBanned = 17, // VAC2 banned
k_EResultConnectFailed = 35, k_EResultAccountNotFound = 18, // account not found
k_EResultHandshakeFailed = 36, k_EResultInvalidSteamID = 19, // steamID is invalid
k_EResultIOFailure = 37, k_EResultServiceUnavailable = 20, // The requested service is currently unavailable
k_EResultRemoteDisconnect = 38, k_EResultNotLoggedOn = 21, // The user is not logged on
k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested k_EResultPending = 22, // Request is pending (may be in process, or waiting on third party)
k_EResultBlocked = 40, // a user didn't allow it k_EResultEncryptionFailure = 23, // Encryption or Decryption failed
k_EResultIgnored = 41, // target is ignoring sender k_EResultInsufficientPrivilege = 24, // Insufficient privilege
k_EResultNoMatch = 42, // nothing matching the request found k_EResultLimitExceeded = 25, // Too much of a good thing
k_EResultAccountDisabled = 43, k_EResultRevoked = 26, // Access has been revoked (used for revoked guest passes)
k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now k_EResultExpired = 27, // License/Guest pass the user is trying to access is expired
k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available k_EResultAlreadyRedeemed = 28, // Guest pass has already been redeemed by account, cannot be acked again
k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin k_EResultDuplicateRequest = 29, // The request is a duplicate and the action has already occurred in the past, ignored this time
k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol. k_EResultAlreadyOwned = 30, // All the games in this guest pass redemption request are already owned by the user
k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another. k_EResultIPNotFound = 31, // IP address not found
k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed. k_EResultPersistFailed = 32, // failed to write change to the data store
k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait k_EResultLockingFailed = 33, // failed to acquire access lock for this operation
k_EResultSuspended = 51, // Long running operation (content download) suspended/paused k_EResultLogonSessionReplaced = 34,
k_EResultCancelled = 52, // Operation canceled (typically by user: content download) k_EResultConnectFailed = 35,
k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable k_EResultHandshakeFailed = 36,
k_EResultDiskFull = 54, // Operation canceled - not enough disk space. k_EResultIOFailure = 37,
k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed k_EResultRemoteDisconnect = 38,
k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side k_EResultShoppingCartNotFound = 39, // failed to find the shopping cart requested
k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account k_EResultBlocked = 40, // a user didn't allow it
k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid k_EResultIgnored = 41, // target is ignoring sender
k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first k_EResultNoMatch = 42, // nothing matching the request found
k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files k_EResultAccountDisabled = 43,
k_EResultIllegalPassword = 61, // The requested new password is not legal k_EResultServiceReadOnly = 44, // this service is not accepting content changes right now
k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer ) k_EResultAccountNotFeatured = 45, // account doesn't have value, so this feature isn't available
k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure k_EResultAdministratorOK = 46, // allowed to take this action, but only because requester is admin
k_EResultCannotUseOldPassword = 64, // The requested new password is not legal k_EResultContentVersion = 47, // A Version mismatch in content transmitted within the Steam protocol.
k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid k_EResultTryAnotherCM = 48, // The current CM can't service the user making a request, user should try another.
k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent k_EResultPasswordRequiredToKickSession = 49,// You are already logged in elsewhere, this cached credential login has failed.
k_EResultHardwareNotCapableOfIPT = 67, // k_EResultAlreadyLoggedInElsewhere = 50, // You are already logged in elsewhere, you must wait
k_EResultIPTInitError = 68, // k_EResultSuspended = 51, // Long running operation (content download) suspended/paused
k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user k_EResultCancelled = 52, // Operation canceled (typically by user: content download)
k_EResultFacebookQueryError = 70, // Facebook query returned an error k_EResultDataCorruption = 53, // Operation canceled because data is ill formed or unrecoverable
k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired k_EResultDiskFull = 54, // Operation canceled - not enough disk space.
k_EResultIPLoginRestrictionFailed = 72, k_EResultRemoteCallFailed = 55, // an remote call or IPC call failed
k_EResultAccountLockedDown = 73, k_EResultPasswordUnset = 56, // Password could not be verified as it's unset server side
k_EResultAccountLogonDeniedVerifiedEmailRequired = 74, k_EResultExternalAccountUnlinked = 57, // External account (PSN, Facebook...) is not linked to a Steam account
k_EResultNoMatchingURL = 75, k_EResultPSNTicketInvalid = 58, // PSN ticket was invalid
k_EResultBadResponse = 76, // parse failure, missing field, etc. k_EResultExternalAccountAlreadyLinked = 59, // External account (PSN, Facebook...) is already linked to some other account, must explicitly request to replace/delete the link first
k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password k_EResultRemoteFileConflict = 60, // The sync cannot resume due to a conflict between the local and remote files
k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range k_EResultIllegalPassword = 61, // The requested new password is not legal
k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen k_EResultSameAsPreviousValue = 62, // new value is the same as the old one ( secret question and answer )
k_EResultDisabled = 80, // The requested service has been configured to be unavailable k_EResultAccountLogonDenied = 63, // account login denied due to 2nd factor authentication failure
k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid ! k_EResultCannotUseOldPassword = 64, // The requested new password is not legal
k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action k_EResultInvalidLoginAuthCode = 65, // account login denied due to auth code invalid
k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted k_EResultAccountLogonDeniedNoMail = 66, // account login denied due to 2nd factor auth failure - and no mail has been sent
k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent k_EResultHardwareNotCapableOfIPT = 67, //
k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login k_EResultIPTInitError = 68, //
k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted k_EResultParentalControlRestricted = 69, // operation failed due to parental control restrictions for current user
k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker k_EResultFacebookQueryError = 70, // Facebook query returned an error
k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch k_EResultExpiredLoginAuthCode = 71, // account login denied due to auth code expired
k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match k_EResultIPLoginRestrictionFailed = 72,
k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners k_EResultAccountLockedDown = 73,
k_EResultNotModified = 91, // data not modified k_EResultAccountLogonDeniedVerifiedEmailRequired = 74,
}; k_EResultNoMatchingURL = 75,
k_EResultBadResponse = 76, // parse failure, missing field, etc.
// Check these to future proof k_EResultRequirePasswordReEntry = 77, // The user cannot complete the action until they re-enter their password
UENUM(BlueprintType) k_EResultValueOutOfRange = 78, // the value entered is outside the acceptable range
enum class FBPWorkshopFileType : uint8 k_EResultUnexpectedError = 79, // something happened that we didn't expect to ever happen
{ k_EResultDisabled = 80, // The requested service has been configured to be unavailable
k_EWorkshopFileTypeCommunity = 0, k_EResultInvalidCEGSubmission = 81, // The set of files submitted to the CEG server are not valid !
k_EWorkshopFileTypeMicrotransaction = 1, k_EResultRestrictedDevice = 82, // The device being used is not allowed to perform this action
k_EWorkshopFileTypeCollection = 2, k_EResultRegionLocked = 83, // The action could not be complete because it is region restricted
k_EWorkshopFileTypeArt = 3, k_EResultRateLimitExceeded = 84, // Temporary rate limit exceeded, try again later, different from k_EResultLimitExceeded which may be permanent
k_EWorkshopFileTypeVideo = 4, k_EResultAccountLoginDeniedNeedTwoFactor = 85, // Need two-factor code to login
k_EWorkshopFileTypeScreenshot = 5, k_EResultItemDeleted = 86, // The thing we're trying to access has been deleted
k_EWorkshopFileTypeGame = 6, k_EResultAccountLoginDeniedThrottle = 87, // login attempt failed, try to throttle response to possible attacker
k_EWorkshopFileTypeSoftware = 7, k_EResultTwoFactorCodeMismatch = 88, // two factor code mismatch
k_EWorkshopFileTypeConcept = 8, k_EResultTwoFactorActivationCodeMismatch = 89, // activation code for two-factor didn't match
k_EWorkshopFileTypeWebGuide = 9, k_EResultAccountAssociatedToMultiplePartners = 90, // account has been associated with multiple partners
k_EWorkshopFileTypeIntegratedGuide = 10, k_EResultNotModified = 91, // data not modified
k_EWorkshopFileTypeMerch = 11, };
k_EWorkshopFileTypeControllerBinding = 12,
k_EWorkshopFileTypeSteamworksAccessInvite = 13, // Check these to future proof
k_EWorkshopFileTypeSteamVideo = 14, UENUM(BlueprintType)
enum class FBPWorkshopFileType : uint8
// Update k_EWorkshopFileTypeMax if you add values. {
k_EWorkshopFileTypeMax = 15 k_EWorkshopFileTypeCommunity = 0,
}; k_EWorkshopFileTypeMicrotransaction = 1,
k_EWorkshopFileTypeCollection = 2,
// WorkshopItemDetails Struct k_EWorkshopFileTypeArt = 3,
USTRUCT(BlueprintType) k_EWorkshopFileTypeVideo = 4,
struct FBPSteamWorkshopItemDetails k_EWorkshopFileTypeScreenshot = 5,
{ k_EWorkshopFileTypeGame = 6,
GENERATED_USTRUCT_BODY() k_EWorkshopFileTypeSoftware = 7,
k_EWorkshopFileTypeConcept = 8,
public: k_EWorkshopFileTypeWebGuide = 9,
FBPSteamWorkshopItemDetails() k_EWorkshopFileTypeIntegratedGuide = 10,
{ k_EWorkshopFileTypeMerch = 11,
k_EWorkshopFileTypeControllerBinding = 12,
} k_EWorkshopFileTypeSteamworksAccessInvite = 13,
k_EWorkshopFileTypeSteamVideo = 14,
FBPSteamWorkshopItemDetails(SteamUGCDetails_t &hUGCDetails)
{ // Update k_EWorkshopFileTypeMax if you add values.
ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult; k_EWorkshopFileTypeMax = 15
FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType; };
CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID;
ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID; // WorkshopItemDetails Struct
Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax); USTRUCT(BlueprintType)
Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax); struct FBPSteamWorkshopItemDetails
ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax); {
VotesUp = (int32)hUGCDetails.m_unVotesUp; GENERATED_USTRUCT_BODY()
VotesDown = (int32)hUGCDetails.m_unVotesDown;
CalculatedScore = hUGCDetails.m_flScore; public:
bBanned = hUGCDetails.m_bBanned;
bAcceptedForUse = hUGCDetails.m_bAcceptedForUse; FBPSteamWorkshopItemDetails()
bTagsTruncated = hUGCDetails.m_bTagsTruncated; {
ResultOfRequest = FBPSteamResult::k_EResultOK;
CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner); FileType = FBPWorkshopFileType::k_EWorkshopFileTypeMax;
} CreatorAppID = 0;
ConsumerAppID = 0;
// Result of obtaining the details VotesUp = 0;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") VotesDown = 0;
FBPSteamResult ResultOfRequest; CalculatedScore = 0.f;
bBanned = false;
// Type of file bAcceptedForUse = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") bTagsTruncated = false;
FBPWorkshopFileType FileType; }
// These two are listed as baked to an int, but is stored as a uint, think its safe to keep int #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") FBPSteamWorkshopItemDetails(SteamUGCDetails_t &hUGCDetails)
int32 CreatorAppID; {
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult;
int32 ConsumerAppID; FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType;
CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID;
// Title of item ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax);
FString Title; Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax);
ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax);
// Description of item VotesUp = (int32)hUGCDetails.m_unVotesUp;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") VotesDown = (int32)hUGCDetails.m_unVotesDown;
FString Description; CalculatedScore = hUGCDetails.m_flScore;
bBanned = hUGCDetails.m_bBanned;
//Url for a video of website bAcceptedForUse = hUGCDetails.m_bAcceptedForUse;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") bTagsTruncated = hUGCDetails.m_bTagsTruncated;
FString ItemUrl;
CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner);
// Votes will be unlikely to go above signed limited }
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
int32 VotesUp; FBPSteamWorkshopItemDetails(const SteamUGCDetails_t &hUGCDetails)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") {
int32 VotesDown; ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult;
FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType;
// Calculated score CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID;
float CalculatedScore; Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax);
Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax);
// whether the file was banned ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax);
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") VotesUp = (int32)hUGCDetails.m_unVotesUp;
bool bBanned; VotesDown = (int32)hUGCDetails.m_unVotesDown;
CalculatedScore = hUGCDetails.m_flScore;
// developer has specifically flagged this item as accepted in the Workshop bBanned = hUGCDetails.m_bBanned;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") bAcceptedForUse = hUGCDetails.m_bAcceptedForUse;
bool bAcceptedForUse; bTagsTruncated = hUGCDetails.m_bTagsTruncated;
// whether the list of tags was too long to be returned in the provided buffer CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner);
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") }
bool bTagsTruncated; #endif
// Steam ID of the user who created this content. // Result of obtaining the details
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FString CreatorSteamID; FBPSteamResult ResultOfRequest;
/* // Type of file
PublishedFileId_t m_nPublishedFileId; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
uint32 m_rtimeCreated; // time when the published file was created FBPWorkshopFileType FileType;
uint32 m_rtimeUpdated; // time when the published file was last updated
uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable) // These two are listed as baked to an int, but is stored as a uint, think its safe to keep int
ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file int32 CreatorAppID;
// file/url information UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
UGCHandle_t m_hFile; // The handle of the primary file int32 ConsumerAppID;
UGCHandle_t m_hPreviewFile; // The handle of the preview file
char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file // Title of item
int32 m_nFileSize; // Size of the primary file UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
int32 m_nPreviewFileSize; // Size of the preview file FString Title;
uint32 m_unNumChildren; // if m_eFileType == k_EWorkshopFileTypeCollection, then this number will be the number of children contained within the collection
*/ // Description of item
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
}; FString Description;
UCLASS() //Url for a video of website
class UAdvancedSteamWorkshopLibrary : public UBlueprintFunctionLibrary UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
{ FString ItemUrl;
GENERATED_BODY()
public: // Votes will be unlikely to go above signed limited
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
//********* Steam Functions *************// int32 VotesUp;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
// Returns IDs for subscribed workshop items, TArray length dictates how many int32 VotesDown;
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop")
static TArray<FBPSteamWorkshopID> GetSubscribedWorkshopItems(int32 & NumberOfItems); // Calculated score
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop") float CalculatedScore;
static void GetNumSubscribedWorkshopItems(int32 & NumberOfItems);
// whether the file was banned
}; UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
bool bBanned;
// developer has specifically flagged this item as accepted in the Workshop
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
bool bAcceptedForUse;
// whether the list of tags was too long to be returned in the provided buffer
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
bool bTagsTruncated;
// Steam ID of the user who created this content.
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
FString CreatorSteamID;
/*
PublishedFileId_t m_nPublishedFileId;
uint32 m_rtimeCreated; // time when the published file was created
uint32 m_rtimeUpdated; // time when the published file was last updated
uint32 m_rtimeAddedToUserList; // time when the user added the published file to their list (not always applicable)
ERemoteStoragePublishedFileVisibility m_eVisibility; // visibility
char m_rgchTags[k_cchTagListMax]; // comma separated list of all tags associated with this file
// file/url information
UGCHandle_t m_hFile; // The handle of the primary file
UGCHandle_t m_hPreviewFile; // The handle of the preview file
char m_pchFileName[k_cchFilenameMax]; // The cloud filename of the primary file
int32 m_nFileSize; // Size of the primary file
int32 m_nPreviewFileSize; // Size of the preview file
uint32 m_unNumChildren; // if m_eFileType == k_EWorkshopFileTypeCollection, then this number will be the number of children contained within the collection
*/
};
UCLASS()
class UAdvancedSteamWorkshopLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
//********* Steam Functions *************//
// Returns IDs for subscribed workshop items, TArray length dictates how many
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop")
static TArray<FBPSteamWorkshopID> GetSubscribedWorkshopItems(int32 & NumberOfItems);
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSteamWorkshop")
static void GetNumSubscribedWorkshopItems(int32 & NumberOfItems);
};

View File

@@ -0,0 +1,87 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Subsystems/GameInstanceSubsystem.h"
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#include <steam/steam_api.h>
#endif
#include "SteamNotificationsSubsystem.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnSteamOverlayActivated, bool, bOverlayState);
UCLASS()
class ADVANCEDSTEAMSESSIONS_API USteamNotificationsSubsystem : public UGameInstanceSubsystem
{
GENERATED_BODY()
public:
// Event thrown when the steam overlay switches states
UPROPERTY(BlueprintAssignable, Category = "SteamEvents")
FOnSteamOverlayActivated OnSteamOverlayActivated_Bind;
USteamNotificationsSubsystem() : Super()
{
}
class cSteamEventsStore
{
public:
USteamNotificationsSubsystem* ParentSubsystem = nullptr;
void Initialize(USteamNotificationsSubsystem* MyParent)
{
ParentSubsystem = MyParent;
}
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
cSteamEventsStore() :
OnExternalUITriggeredCallback(this, &cSteamEventsStore::OnExternalUITriggered)
{
}
#else
//cSteamEventsStore()
//{
//}
#endif
//~cSteamEventsStore(){}
private:
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
STEAM_CALLBACK(cSteamEventsStore, OnExternalUITriggered, GameOverlayActivated_t, OnExternalUITriggeredCallback);
#endif
};
cSteamEventsStore MyEvents;
/** Implement this for initialization of instances of the system */
virtual void Initialize(FSubsystemCollectionBase& Collection) override
{
MyEvents.Initialize(this);
}
/** Implement this for deinitialization of instances of the system */
virtual void Deinitialize() override
{
}
};
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
void USteamNotificationsSubsystem::cSteamEventsStore::OnExternalUITriggered(GameOverlayActivated_t* CallbackData)
{
if (ParentSubsystem)
{
ParentSubsystem->OnSteamOverlayActivated_Bind.Broadcast((bool)CallbackData->m_bActive);
}
}
#endif

View File

@@ -4,45 +4,59 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just // @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK // disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4996) #pragma warning(disable:4996)
#endif // #TODO check back on this at some point
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #endif
#pragma push_macro("ARRAY_COUNT") #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#undef ARRAY_COUNT
//#include "OnlineSubsystemSteam.h"
#include <steam/steam_api.h>
#pragma push_macro("ARRAY_COUNT")
#pragma pop_macro("ARRAY_COUNT") #undef ARRAY_COUNT
#endif #if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(push))
// @todo Steam: See above MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#ifdef _MSC_VER #endif // USING_CODE_ANALYSIS
#pragma warning(pop)
#include <steam/steam_api.h>
#if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(pop))
#endif // USING_CODE_ANALYSIS
#pragma pop_macro("ARRAY_COUNT")
#endif
// @todo Steam: See above
#ifdef _MSC_VER
#pragma warning(pop)
#endif #endif
#include "SteamRequestGroupOfficersCallbackProxy.generated.h" #include "SteamRequestGroupOfficersCallbackProxy.generated.h"
USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups") USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups")
struct FBPSteamGroupOfficer struct FBPSteamGroupOfficer
{ {
GENERATED_USTRUCT_BODY() GENERATED_USTRUCT_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
FBPUniqueNetId OfficerUniqueNetID; // Uint64 representation FBPUniqueNetId OfficerUniqueNetID; // Uint64 representation
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
bool bIsOwner; bool bIsOwner = false;
}; };
@@ -53,6 +67,8 @@ class USteamRequestGroupOfficersCallbackProxy : public UOnlineBlueprintCallProxy
{ {
GENERATED_UCLASS_BODY() GENERATED_UCLASS_BODY()
virtual ~USteamRequestGroupOfficersCallbackProxy();
// Called when there is a successful results return // Called when there is a successful results return
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGroupOfficerDetailsDelegate OnSuccess; FBlueprintGroupOfficerDetailsDelegate OnSuccess;
@@ -61,7 +77,7 @@ class USteamRequestGroupOfficersCallbackProxy : public UOnlineBlueprintCallProxy
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FBlueprintGroupOfficerDetailsDelegate OnFailure; FBlueprintGroupOfficerDetailsDelegate OnFailure;
// Retruns a list of steam group officers // Returns a list of steam group officers
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|SteamAPI|SteamGroups") UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|SteamAPI|SteamGroups")
static USteamRequestGroupOfficersCallbackProxy* GetSteamGroupOfficerList(UObject* WorldContextObject, FBPUniqueNetId GroupUniqueNetID); static USteamRequestGroupOfficersCallbackProxy* GetSteamGroupOfficerList(UObject* WorldContextObject, FBPUniqueNetId GroupUniqueNetID);
@@ -70,10 +86,11 @@ class USteamRequestGroupOfficersCallbackProxy : public UOnlineBlueprintCallProxy
// End of UOnlineBlueprintCallProxyBase interface // End of UOnlineBlueprintCallProxyBase interface
private: private:
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
void OnRequestGroupOfficerDetails( ClanOfficerListResponse_t *pResult, bool bIOFailure); void OnRequestGroupOfficerDetails( ClanOfficerListResponse_t *pResult, bool bIOFailure);
CCallResult<USteamRequestGroupOfficersCallbackProxy, ClanOfficerListResponse_t> m_callResultGroupOfficerRequestDetails; CCallResult<USteamRequestGroupOfficersCallbackProxy, ClanOfficerListResponse_t> m_callResultGroupOfficerRequestDetails;
#endif #endif
private: private:

View File

@@ -5,31 +5,46 @@
#include "AdvancedSteamWorkshopLibrary.h" #include "AdvancedSteamWorkshopLibrary.h"
#include "BlueprintDataDefinitions.h" #include "BlueprintDataDefinitions.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro // This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just // @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK // disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)
#pragma warning(disable:4996) #pragma warning(disable:4996)
#endif // #TODO check back on this at some point
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
#pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT
#include <steam/steam_api.h>
#pragma pop_macro("ARRAY_COUNT")
#endif
// @todo Steam: See above
#ifdef _MSC_VER
#pragma warning(pop)
#endif #endif
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
//#include "OnlineSubsystemSteam.h"
#pragma push_macro("ARRAY_COUNT")
#undef ARRAY_COUNT
#if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(push))
MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
#endif // USING_CODE_ANALYSIS
#include <steam/steam_api.h>
#if USING_CODE_ANALYSIS
MSVC_PRAGMA(warning(pop))
#endif // USING_CODE_ANALYSIS
#pragma pop_macro("ARRAY_COUNT")
#endif
// @todo Steam: See above
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "SteamWSRequestUGCDetailsCallbackProxy.generated.h" #include "SteamWSRequestUGCDetailsCallbackProxy.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintWorkshopDetailsDelegate, const FBPSteamWorkshopItemDetails&, WorkShopDetails); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FBlueprintWorkshopDetailsDelegate, const FBPSteamWorkshopItemDetails&, WorkShopDetails);
@@ -57,10 +72,10 @@ class USteamWSRequestUGCDetailsCallbackProxy : public UOnlineBlueprintCallProxyB
private: private:
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
// Internal callback when the operation completes, calls out to the public success/failure callbacks // Internal callback when the operation completes, calls out to the public success/failure callbacks
void OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure); void OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure);
CCallResult<USteamWSRequestUGCDetailsCallbackProxy, SteamUGCQueryCompleted_t> m_callResultUGCRequestDetails; CCallResult<USteamWSRequestUGCDetailsCallbackProxy, SteamUGCQueryCompleted_t> m_callResultUGCRequestDetails;
#endif #endif

View File

@@ -1,338 +1,438 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedSteamFriendsLibrary.h" #include "AdvancedSteamFriendsLibrary.h"
#include "OnlineSubSystemHeader.h" #include "OnlineSubSystemHeader.h"
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro //General Log
DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog);
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
// disable the warnings locally. Remove when this is fixed in the SDK
#ifdef _MSC_VER // Clan functions, add in soon
#pragma warning(push) /*int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId)
#pragma warning(disable:4996) {
#endif
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{
#pragma push_macro("ARRAY_COUNT") UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
#undef ARRAY_COUNT return 0;
}
#include <steam/steam_api.h>
#include <steam/isteamapps.h> if (SteamAPI_Init())
#include <steam/isteamapplist.h> {
#include <OnlineSubsystemSteamTypes.h> uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
#pragma pop_macro("ARRAY_COUNT")
#endif // clan (group) iteration and access functions
//virtual int GetClanCount() = 0;
// @todo Steam: See above //virtual CSteamID GetClanByIndex(int iClan) = 0;
#ifdef _MSC_VER //virtual const char *GetClanName(CSteamID steamIDClan) = 0;
#pragma warning(pop) //virtual const char *GetClanTag(CSteamID steamIDClan) = 0;
#endif // returns the most recent information we have about what's happening in a clan
//virtual bool GetClanActivityCounts(CSteamID steamIDClan, int *pnOnline, int *pnInGame, int *pnChatting) = 0;
//General Log // for clans a user is a member of, they will have reasonably up-to-date information, but for others you'll have to download the info to have the latest
DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog); //virtual SteamAPICall_t DownloadClanActivityCounts(ARRAY_COUNT(cClansToRequest) CSteamID *psteamIDClans, int cClansToRequest) = 0;
// requests information about a clan officer list
// Clan functions, add in soon // when complete, data is returned in ClanOfficerListResponse_t call result
/*int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId) // this makes available the calls below
{ // you can only ask about clans that a user is a member of
// note that this won't download avatars automatically; if you get an officer,
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX // and no avatar image is available, call RequestUserInformation( steamID, false ) to download the avatar
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) //virtual SteamAPICall_t RequestClanOfficerList(CSteamID steamIDClan) = 0;
{
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
return 0; // returns the steamID of the clan owner
} //virtual CSteamID GetClanOwner(CSteamID steamIDClan) = 0;
// returns the number of officers in a clan (including the owner)
if (SteamAPI_Init()) //virtual int GetClanOfficerCount(CSteamID steamIDClan) = 0;
{ // returns the steamID of a clan officer, by index, of range [0,GetClanOfficerCount)
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); //virtual CSteamID GetClanOfficerByIndex(CSteamID steamIDClan, int iOfficer) = 0;
// clan (group) iteration and access functions return SteamFriends()->GetFriendSteamLevel(id);
//virtual int GetClanCount() = 0; }
//virtual CSteamID GetClanByIndex(int iClan) = 0; #endif
//virtual const char *GetClanName(CSteamID steamIDClan) = 0;
//virtual const char *GetClanTag(CSteamID steamIDClan) = 0; return 0;
// returns the most recent information we have about what's happening in a clan }*/
//virtual bool GetClanActivityCounts(CSteamID steamIDClan, int *pnOnline, int *pnInGame, int *pnChatting) = 0;
// for clans a user is a member of, they will have reasonably up-to-date information, but for others you'll have to download the info to have the latest void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups)
//virtual SteamAPICall_t DownloadClanActivityCounts(ARRAY_COUNT(cClansToRequest) CSteamID *psteamIDClans, int cClansToRequest) = 0; {
// requests information about a clan officer list #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
// when complete, data is returned in ClanOfficerListResponse_t call result
// this makes available the calls below if (SteamAPI_Init())
// you can only ask about clans that a user is a member of {
// note that this won't download avatars automatically; if you get an officer, int numClans = SteamFriends()->GetClanCount();
// and no avatar image is available, call RequestUserInformation( steamID, false ) to download the avatar
//virtual SteamAPICall_t RequestClanOfficerList(CSteamID steamIDClan) = 0; for (int i = 0; i < numClans; i++)
{
CSteamID SteamGroupID = SteamFriends()->GetClanByIndex(i);
// returns the steamID of the clan owner
//virtual CSteamID GetClanOwner(CSteamID steamIDClan) = 0; if(!SteamGroupID.IsValid())
// returns the number of officers in a clan (including the owner) continue;
//virtual int GetClanOfficerCount(CSteamID steamIDClan) = 0;
// returns the steamID of a clan officer, by index, of range [0,GetClanOfficerCount) FBPSteamGroupInfo GroupInfo;
//virtual CSteamID GetClanOfficerByIndex(CSteamID steamIDClan, int iOfficer) = 0;
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamGroupID));
GroupInfo.GroupID.SetUniqueNetId(ValueID);
return SteamFriends()->GetFriendSteamLevel(id); SteamFriends()->GetClanActivityCounts(SteamGroupID, &GroupInfo.numOnline, &GroupInfo.numInGame, &GroupInfo.numChatting);
} GroupInfo.GroupName = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanName(SteamGroupID)));
#endif GroupInfo.GroupTag = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanTag(SteamGroupID)));
return 0; SteamGroups.Add(GroupInfo);
}*/ }
}
void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups) #endif
{
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX }
if (SteamAPI_Init()) void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID)
{ {
int numClans = SteamFriends()->GetClanCount();
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
for (int i = 0; i < numClans; i++) if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{ {
CSteamID SteamGroupID = SteamFriends()->GetClanByIndex(i); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendGamePlayed Had a bad UniqueNetId!"));
Result = EBlueprintResultSwitch::OnFailure;
if(!SteamGroupID.IsValid()) return;
continue; }
FBPSteamGroupInfo GroupInfo; if (SteamAPI_Init())
{
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam(SteamGroupID)); uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
GroupInfo.GroupID.SetUniqueNetId(ValueID);
SteamFriends()->GetClanActivityCounts(SteamGroupID, &GroupInfo.numOnline, &GroupInfo.numInGame, &GroupInfo.numChatting); FriendGameInfo_t GameInfo;
GroupInfo.GroupName = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanName(SteamGroupID))); bool bIsInGame = SteamFriends()->GetFriendGamePlayed(id, &GameInfo);
GroupInfo.GroupTag = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanTag(SteamGroupID)));
if (bIsInGame && GameInfo.m_gameID.IsValid())
SteamGroups.Add(GroupInfo); {
} AppID = GameInfo.m_gameID.AppID();
}
#endif // Forgot this test and left it in, it is incorrect, you would need restricted access
} // And it would only find games in the local library anyway
/*char NameBuffer[512];
void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result, FString & GameName, int32 & AppID) int Len = SteamAppList()->GetAppName(GameInfo.m_gameID.AppID(), NameBuffer, 512);
{
if (Len != -1) // Invalid
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX {
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) GameName = FString(UTF8_TO_TCHAR(NameBuffer));
{ }*/
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendGamePlayed Had a bad UniqueNetId!"));
Result = EBlueprintResultSwitch::OnFailure; Result = EBlueprintResultSwitch::OnSuccess;
return; return;
} }
if (SteamAPI_Init()) }
{ #endif
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
Result = EBlueprintResultSwitch::OnFailure;
FriendGameInfo_t GameInfo; }
bool bIsInGame = SteamFriends()->GetFriendGamePlayed(id, &GameInfo);
int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId)
if (bIsInGame && GameInfo.m_gameID.IsValid()) {
{
AppID = GameInfo.m_gameID.AppID(); #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
char NameBuffer[512]; {
int Len = SteamAppList()->GetAppName(GameInfo.m_gameID.AppID(), NameBuffer, 512); UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
return 0;
if (Len != -1) // Invalid }
{
GameName = FString(UTF8_TO_TCHAR(NameBuffer)); if (SteamAPI_Init())
} {
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
Result = EBlueprintResultSwitch::OnSuccess;
return; return SteamFriends()->GetFriendSteamLevel(id);
} }
#endif
}
#endif return 0;
}
Result = EBlueprintResultSwitch::OnFailure;
} FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId UniqueNetId)
{
int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId)
{ #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX {
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamPersonaName Had a bad UniqueNetId!"));
{ return FString(TEXT(""));
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!")); }
return 0;
} if (SteamAPI_Init())
{
if (SteamAPI_Init()) uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
{ const char* PersonaName = SteamFriends()->GetFriendPersonaName(id);
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); return FString(UTF8_TO_TCHAR(PersonaName));
}
return SteamFriends()->GetFriendSteamLevel(id); #endif
}
#endif return FString(TEXT(""));
}
return 0;
} FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FString SteamID64)
{
FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId UniqueNetId) FBPUniqueNetId netId;
{
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX if (!(SteamID64.Len() > 0))
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) {
{ UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("CreateSteamIDFromString Had a bad UniqueNetId!"));
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamPersonaName Had a bad UniqueNetId!")); return netId;
return FString(TEXT("")); }
}
if (SteamAPI_Init())
if (SteamAPI_Init()) {
{ // Already does the conversion
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamID64));
const char* PersonaName = SteamFriends()->GetFriendPersonaName(id); //FCString::Atoi64(*SteamID64));
return FString(UTF8_TO_TCHAR(PersonaName));
} netId.SetUniqueNetId(ValueID);
#endif return netId;
}
return FString(TEXT("")); #endif
}
return netId;
FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FString SteamID64) }
{
FBPUniqueNetId netId; FBPUniqueNetId UAdvancedSteamFriendsLibrary::GetLocalSteamIDFromSteam()
{
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX FBPUniqueNetId netId;
if (!(SteamID64.Len() > 0))
{ #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("CreateSteamIDFromString Had a bad UniqueNetId!")); if (SteamAPI_Init())
return netId; {
} TSharedPtr<const FUniqueNetId> SteamID(new const FUniqueNetIdSteam2(SteamUser()->GetSteamID()));
netId.SetUniqueNetId(SteamID);
if (SteamAPI_Init()) }
{ #endif
// Already does the conversion
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam(SteamID64)); return netId;
//FCString::Atoi64(*SteamID64)); }
netId.SetUniqueNetId(ValueID); bool UAdvancedSteamFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly)
return netId; {
} #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#endif if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
{
return netId; UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Had a bad UniqueNetId!"));
} return false;
}
bool UAdvancedSteamFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly)
{ if (SteamAPI_Init())
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX {
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
{
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Had a bad UniqueNetId!")); return !SteamFriends()->RequestUserInformation(id, bRequireNameOnly);
return false; }
} #endif
if (SteamAPI_Init()) UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Couldn't init steamAPI!"));
{ return false;
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); }
return !SteamFriends()->RequestUserInformation(id, bRequireNameOnly);
} bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType)
#endif {
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Couldn't init steamAPI!")); if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
return false; {
} UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Had a bad UniqueNetId!"));
return false;
UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize) }
{
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX if (SteamAPI_Init())
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid()) {
{ uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendAvatar Had a bad UniqueNetId!")); if (DialogType == ESteamUserOverlayType::invitetolobby)
Result = EBlueprintAsyncResultSwitch::OnFailure; {
return nullptr; SteamFriends()->ActivateGameOverlayInviteDialog(id);
} }
else
uint32 Width = 0; {
uint32 Height = 0; FString DialogName = EnumToString("ESteamUserOverlayType", (uint8)DialogType);
SteamFriends()->ActivateGameOverlayToUser(TCHAR_TO_ANSI(*DialogName), id);
if (SteamAPI_Init()) }
{ return true;
//Getting the PictureID from the SteamAPI and getting the Size with the ID }
//virtual bool RequestUserInformation( CSteamID steamIDUser, bool bRequireNameOnly ) = 0; #endif
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!"));
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes()); return false;
int Picture = 0; }
switch(AvatarSize) bool UAdvancedSteamFriendsLibrary::IsOverlayEnabled()
{ {
case SteamAvatarSize::SteamAvatar_Small: Picture = SteamFriends()->GetSmallFriendAvatar(id); break; #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
case SteamAvatarSize::SteamAvatar_Medium: Picture = SteamFriends()->GetMediumFriendAvatar(id); break; if (SteamAPI_Init())
case SteamAvatarSize::SteamAvatar_Large: Picture = SteamFriends()->GetLargeFriendAvatar(id); break; {
default: break; return SteamUtils()->IsOverlayEnabled();
} }
#endif
if (Picture == -1)
{ UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!"));
Result = EBlueprintAsyncResultSwitch::AsyncLoading; return false;
return NULL; }
}
UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize)
SteamUtils()->GetImageSize(Picture, &Width, &Height); {
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
// STOLEN FROM ANSWERHUB :p, then fixed because answerhub wasn't releasing the memory O.o if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
// Also fixed image pixel format and switched to a memcpy instead of manual iteration. {
// At some point I should probably reply to that answerhub post with these fixes to prevent people killing their games..... UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendAvatar Had a bad UniqueNetId!"));
Result = EBlueprintAsyncResultSwitch::OnFailure;
if (Width > 0 && Height > 0) return nullptr;
{ }
//Creating the buffer "oAvatarRGBA" and then filling it with the RGBA Stream from the Steam Avatar
uint8 *oAvatarRGBA = new uint8[Width * Height * 4]; uint32 Width = 0;
uint32 Height = 0;
//Filling the buffer with the RGBA Stream from the Steam Avatar and creating a UTextur2D to parse the RGBA Steam in if (SteamAPI_Init())
SteamUtils()->GetImageRGBA(Picture, (uint8*)oAvatarRGBA, 4 * Height * Width * sizeof(char)); {
//Getting the PictureID from the SteamAPI and getting the Size with the ID
//virtual bool RequestUserInformation( CSteamID steamIDUser, bool bRequireNameOnly ) = 0;
// Removed as I changed the image bit code to be RGB, I think the original author was unaware that there were different pixel formats
/*
//Swap R and B channels because for some reason the games whack uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
for (uint32 i = 0; i < (Width * Height * 4); i += 4) int Picture = 0;
{
uint8 Temp = oAvatarRGBA[i + 0]; switch(AvatarSize)
oAvatarRGBA[i + 0] = oAvatarRGBA[i + 2]; {
oAvatarRGBA[i + 2] = Temp; case SteamAvatarSize::SteamAvatar_Small: Picture = SteamFriends()->GetSmallFriendAvatar(id); break;
}*/ case SteamAvatarSize::SteamAvatar_Medium: Picture = SteamFriends()->GetMediumFriendAvatar(id); break;
case SteamAvatarSize::SteamAvatar_Large: Picture = SteamFriends()->GetLargeFriendAvatar(id); break;
UTexture2D* Avatar = UTexture2D::CreateTransient(Width, Height, PF_R8G8B8A8); default: break;
// Switched to a Memcpy instead of byte by byte transer }
uint8* MipData = (uint8*)Avatar->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(MipData, (void*)oAvatarRGBA, Height * Width * 4); if (Picture == -1)
Avatar->PlatformData->Mips[0].BulkData.Unlock(); {
Result = EBlueprintAsyncResultSwitch::AsyncLoading;
// Original implementation was missing this!! return NULL;
// the hell man...... }
delete[] oAvatarRGBA;
SteamUtils()->GetImageSize(Picture, &Width, &Height);
//Setting some Parameters for the Texture and finally returning it
Avatar->PlatformData->NumSlices = 1; // STOLEN FROM ANSWERHUB :p, then fixed because answerhub wasn't releasing the memory O.o
Avatar->NeverStream = true; // Also fixed image pixel format and switched to a memcpy instead of manual iteration.
//Avatar->CompressionSettings = TC_EditorIcon; // At some point I should probably reply to that answerhub post with these fixes to prevent people killing their games.....
Avatar->UpdateResource(); if (Width > 0 && Height > 0)
{
Result = EBlueprintAsyncResultSwitch::OnSuccess; //Creating the buffer "oAvatarRGBA" and then filling it with the RGBA Stream from the Steam Avatar
return Avatar; uint8 *oAvatarRGBA = new uint8[Width * Height * 4];
}
else
{ //Filling the buffer with the RGBA Stream from the Steam Avatar and creating a UTextur2D to parse the RGBA Steam in
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("Bad Height / Width with steam avatar!")); SteamUtils()->GetImageRGBA(Picture, (uint8*)oAvatarRGBA, 4 * Height * Width * sizeof(char));
}
Result = EBlueprintAsyncResultSwitch::OnFailure; // Removed as I changed the image bit code to be RGB, I think the original author was unaware that there were different pixel formats
return nullptr; /*
} //Swap R and B channels because for some reason the games whack
#endif for (uint32 i = 0; i < (Width * Height * 4); i += 4)
{
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized")); uint8 Temp = oAvatarRGBA[i + 0];
Result = EBlueprintAsyncResultSwitch::OnFailure; oAvatarRGBA[i + 0] = oAvatarRGBA[i + 2];
return nullptr; oAvatarRGBA[i + 2] = Temp;
}*/
UTexture2D* Avatar = UTexture2D::CreateTransient(Width, Height, PF_R8G8B8A8);
// Switched to a Memcpy instead of byte by byte transer
if (FTexturePlatformData* PlatformData = Avatar->GetPlatformData())
{
uint8* MipData = (uint8*)PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(MipData, (void*)oAvatarRGBA, Height * Width * 4);
PlatformData->Mips[0].BulkData.Unlock();
//Setting some Parameters for the Texture and finally returning it
PlatformData->SetNumSlices(1);
Avatar->NeverStream = true;
//Avatar->CompressionSettings = TC_EditorIcon;
}
// Free RGBA buffer regardless of whether it was used or not
delete[] oAvatarRGBA;
Avatar->UpdateResource();
Result = EBlueprintAsyncResultSwitch::OnSuccess;
return Avatar;
}
else
{
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("Bad Height / Width with steam avatar!"));
}
Result = EBlueprintAsyncResultSwitch::OnFailure;
return nullptr;
}
#endif
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized"));
Result = EBlueprintAsyncResultSwitch::OnFailure;
return nullptr;
}
bool UAdvancedSteamFriendsLibrary::InitTextFiltering()
{
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (SteamAPI_Init())
{
return SteamUtils()->InitFilterText();
}
#endif
return false;
}
bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText)
{
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (SteamAPI_Init())
{
uint32 BufferLen = TextToFilter.Len() + 10; // Docs say 1 byte excess min, going with 10
char* OutText = new char[BufferLen];
uint64 id = 0;
if (TextSourceID.IsValid())
{
id = *((uint64*)TextSourceID.UniqueNetId->GetBytes());
}
int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen);
if (FilterCount > 0)
{
FilteredText = FString(UTF8_TO_TCHAR(OutText));
delete[] OutText;
return true;
}
delete[] OutText;
}
#endif
FilteredText = TextToFilter;
return false;
}
bool UAdvancedSteamFriendsLibrary::IsSteamInBigPictureMode()
{
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (SteamAPI_Init())
{
return SteamUtils()->IsSteamInBigPictureMode();
}
#endif
return false;
} }

View File

@@ -1,12 +1,12 @@
//#include "StandAlonePrivatePCH.h" //#include "StandAlonePrivatePCH.h"
#include "AdvancedSteamSessions.h" #include "AdvancedSteamSessions.h"
void AdvancedSteamSessions::StartupModule() void AdvancedSteamSessions::StartupModule()
{ {
} }
void AdvancedSteamSessions::ShutdownModule() void AdvancedSteamSessions::ShutdownModule()
{ {
} }
IMPLEMENT_MODULE(AdvancedSteamSessions, AdvancedSteamSessions) IMPLEMENT_MODULE(AdvancedSteamSessions, AdvancedSteamSessions)

View File

@@ -1,69 +1,69 @@
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "AdvancedSteamWorkshopLibrary.h" #include "AdvancedSteamWorkshopLibrary.h"
#include "OnlineSubSystemHeader.h" #include "OnlineSubSystemHeader.h"
//General Log //General Log
DEFINE_LOG_CATEGORY(AdvancedSteamWorkshopLog); DEFINE_LOG_CATEGORY(AdvancedSteamWorkshopLog);
void UAdvancedSteamWorkshopLibrary::GetNumSubscribedWorkshopItems(int32 & NumberOfItems) void UAdvancedSteamWorkshopLibrary::GetNumSubscribedWorkshopItems(int32 & NumberOfItems)
{ {
NumberOfItems = 0; NumberOfItems = 0;
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
NumberOfItems = SteamUGC()->GetNumSubscribedItems(); NumberOfItems = SteamUGC()->GetNumSubscribedItems();
return; return;
} }
else else
{ {
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : SteamAPI is not Inited!")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : SteamAPI is not Inited!"));
return; return;
} }
#endif #endif
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : Called on an incompatible platform")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetNumSubscribedWorkshopItemCount : Called on an incompatible platform"));
return; return;
} }
TArray<FBPSteamWorkshopID> UAdvancedSteamWorkshopLibrary::GetSubscribedWorkshopItems(int32 & NumberOfItems) TArray<FBPSteamWorkshopID> UAdvancedSteamWorkshopLibrary::GetSubscribedWorkshopItems(int32 & NumberOfItems)
{ {
TArray<FBPSteamWorkshopID> outArray; TArray<FBPSteamWorkshopID> outArray;
NumberOfItems = 0; NumberOfItems = 0;
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint32 NumItems = SteamUGC()->GetNumSubscribedItems(); uint32 NumItems = SteamUGC()->GetNumSubscribedItems();
if (NumItems == 0) if (NumItems == 0)
return outArray; return outArray;
// Not using the actual variable above in case someone somehow goes past int32 limits // Not using the actual variable above in case someone somehow goes past int32 limits
// Don't want to go negative on the iteration. // Don't want to go negative on the iteration.
NumberOfItems = NumItems; NumberOfItems = NumItems;
PublishedFileId_t *fileIds = new PublishedFileId_t[NumItems]; PublishedFileId_t *fileIds = new PublishedFileId_t[NumItems];
uint32 subItems = SteamUGC()->GetSubscribedItems(fileIds, NumItems); uint32 subItems = SteamUGC()->GetSubscribedItems(fileIds, NumItems);
for (uint32 i = 0; i < subItems; ++i) for (uint32 i = 0; i < subItems; ++i)
{ {
outArray.Add(FBPSteamWorkshopID(fileIds[i])); outArray.Add(FBPSteamWorkshopID(fileIds[i]));
} }
delete[] fileIds; delete[] fileIds;
return outArray; return outArray;
} }
else else
{ {
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : SteamAPI is not Inited!")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : SteamAPI is not Inited!"));
return outArray; return outArray;
} }
#endif #endif
UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : Called on an incompatible platform")); UE_LOG(AdvancedSteamWorkshopLog, Warning, TEXT("Error in GetSubscribedWorkshopItemCount : Called on an incompatible platform"));
return outArray; return outArray;
} }

View File

@@ -1,7 +1,13 @@
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "SteamRequestGroupOfficersCallbackProxy.h" #include "SteamRequestGroupOfficersCallbackProxy.h"
#include "Online/CoreOnline.h"
#include "AdvancedSteamFriendsLibrary.h"
#include "OnlineSubSystemHeader.h" #include "OnlineSubSystemHeader.h"
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#include "steam/isteamfriends.h"
#endif
//#include "OnlineSubsystemSteamTypes.h"
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UEndSessionCallbackProxy // UEndSessionCallbackProxy
@@ -11,6 +17,9 @@ USteamRequestGroupOfficersCallbackProxy::USteamRequestGroupOfficersCallbackProxy
{ {
} }
USteamRequestGroupOfficersCallbackProxy::~USteamRequestGroupOfficersCallbackProxy()
{
}
USteamRequestGroupOfficersCallbackProxy* USteamRequestGroupOfficersCallbackProxy::GetSteamGroupOfficerList(UObject* WorldContextObject, FBPUniqueNetId GroupUniqueNetID) USteamRequestGroupOfficersCallbackProxy* USteamRequestGroupOfficersCallbackProxy::GetSteamGroupOfficerList(UObject* WorldContextObject, FBPUniqueNetId GroupUniqueNetID)
{ {
@@ -21,13 +30,13 @@ USteamRequestGroupOfficersCallbackProxy* USteamRequestGroupOfficersCallbackProxy
} }
void USteamRequestGroupOfficersCallbackProxy::Activate() void USteamRequestGroupOfficersCallbackProxy::Activate()
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes()); uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes());
SteamAPICall_t hSteamAPICall = SteamFriends()->RequestClanOfficerList(id); SteamAPICall_t hSteamAPICall = SteamFriends()->RequestClanOfficerList(id);
m_callResultGroupOfficerRequestDetails.Set(hSteamAPICall, this, &USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails); m_callResultGroupOfficerRequestDetails.Set(hSteamAPICall, this, &USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails);
return; return;
} }
@@ -36,48 +45,77 @@ void USteamRequestGroupOfficersCallbackProxy::Activate()
OnFailure.Broadcast(EmptyArray); OnFailure.Broadcast(EmptyArray);
} }
void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanOfficerListResponse_t *pResult, bool bIOFailure) #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
{ void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanOfficerListResponse_t *pResult, bool bIOFailure)
TArray<FBPSteamGroupOfficer> OfficerArray; {
TArray<FBPSteamGroupOfficer> OfficerArray;
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
//FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM));
if (bIOFailure || !pResult || !pResult->m_bSuccess)
{ if (bIOFailure || !pResult || !pResult->m_bSuccess)
OnFailure.Broadcast(OfficerArray); {
return; //if (SteamSubsystem != nullptr)
} {
// SteamSubsystem->ExecuteNextTick([this]()
if (SteamAPI_Init()) //{
{ TArray<FBPSteamGroupOfficer> FailureArray;
uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes()); OnFailure.Broadcast(FailureArray);
//});
FBPSteamGroupOfficer Officer; }
CSteamID ClanOwner = SteamFriends()->GetClanOwner(id); //OnFailure.Broadcast(OfficerArray);
return;
Officer.bIsOwner = true; }
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam(ClanOwner)); if (SteamAPI_Init())
Officer.OfficerUniqueNetID.SetUniqueNetId(ValueID); {
OfficerArray.Add(Officer); uint64 id = *((uint64*)GroupUniqueID.UniqueNetId->GetBytes());
for (int i = 0; i < pResult->m_cOfficers; i++) FBPSteamGroupOfficer Officer;
{ CSteamID ClanOwner = SteamFriends()->GetClanOwner(id);
CSteamID OfficerSteamID = SteamFriends()->GetClanOfficerByIndex(id, i);
Officer.bIsOwner = true;
Officer.bIsOwner = false;
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(ClanOwner));
TSharedPtr<const FUniqueNetId> newValueID(new const FUniqueNetIdSteam(OfficerSteamID)); Officer.OfficerUniqueNetID.SetUniqueNetId(ValueID);
Officer.OfficerUniqueNetID.SetUniqueNetId(newValueID); OfficerArray.Add(Officer);
OfficerArray.Add(Officer); for (int i = 0; i < pResult->m_cOfficers; i++)
} {
CSteamID OfficerSteamID = SteamFriends()->GetClanOfficerByIndex(id, i);
OnSuccess.Broadcast(OfficerArray);
return; Officer.bIsOwner = false;
}
#endif TSharedPtr<const FUniqueNetId> newValueID(new const FUniqueNetIdSteam2(OfficerSteamID));
Officer.OfficerUniqueNetID.SetUniqueNetId(newValueID);
OnFailure.Broadcast(OfficerArray);
} OfficerArray.Add(Officer);
}
//if (SteamSubsystem != nullptr)
//{
//SteamSubsystem->ExecuteNextTick([OfficerArray, this]()
//{
OnSuccess.Broadcast(OfficerArray);
//});
//}
//OnSuccess.Broadcast(OfficerArray);
return;
}
else
{
//if (SteamSubsystem != nullptr)
{
//SteamSubsystem->ExecuteNextTick([this]()
//{
TArray<FBPSteamGroupOfficer> FailureArray;
OnFailure.Broadcast(FailureArray);
//});
}
}
// Should never hit this anyway
//OnFailure.Broadcast(OfficerArray);
}
#endif

View File

@@ -2,6 +2,9 @@
#include "SteamWSRequestUGCDetailsCallbackProxy.h" #include "SteamWSRequestUGCDetailsCallbackProxy.h"
#include "OnlineSubSystemHeader.h" #include "OnlineSubSystemHeader.h"
#if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
#include "steam/isteamugc.h"
#endif
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// UEndSessionCallbackProxy // UEndSessionCallbackProxy
@@ -21,13 +24,13 @@ USteamWSRequestUGCDetailsCallbackProxy* USteamWSRequestUGCDetailsCallbackProxy::
} }
void USteamWSRequestUGCDetailsCallbackProxy::Activate() void USteamWSRequestUGCDetailsCallbackProxy::Activate()
{ {
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
if (SteamAPI_Init()) if (SteamAPI_Init())
{ {
// #TODO: Support arrays instead in the future? // #TODO: Support arrays instead in the future?
UGCQueryHandle_t hQueryHandle = SteamUGC()->CreateQueryUGCDetailsRequest((PublishedFileId_t *)&WorkShopID.SteamWorkshopID, 1); UGCQueryHandle_t hQueryHandle = SteamUGC()->CreateQueryUGCDetailsRequest((PublishedFileId_t *)&WorkShopID.SteamWorkshopID, 1);
// #TODO: add search settings here by calling into the handle? // #TODO: add search settings here by calling into the handle?
SteamAPICall_t hSteamAPICall = SteamUGC()->SendQueryUGCRequest(hQueryHandle); SteamAPICall_t hSteamAPICall = SteamUGC()->SendQueryUGCRequest(hQueryHandle);
// Need to release the query // Need to release the query
@@ -46,26 +49,53 @@ void USteamWSRequestUGCDetailsCallbackProxy::Activate()
OnFailure.Broadcast(FBPSteamWorkshopItemDetails()); OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
} }
void USteamWSRequestUGCDetailsCallbackProxy::OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure) #if STEAM_SDK_INSTALLED && (PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX)
{ void USteamWSRequestUGCDetailsCallbackProxy::OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure)
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX {
//FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM));
if (bIOFailure || !pResult || pResult->m_unNumResultsReturned <= 0)
{ if (bIOFailure || !pResult || pResult->m_unNumResultsReturned <= 0)
OnFailure.Broadcast(FBPSteamWorkshopItemDetails()); {
return; //if (SteamSubsystem != nullptr)
} {
if (SteamAPI_Init()) // SteamSubsystem->ExecuteNextTick([this]()
{ //{
SteamUGCDetails_t Details; OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
if (SteamUGC()->GetQueryUGCResult(pResult->m_handle, 0, &Details)) //});
{ }
OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details)); //OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
return; return;
} }
} if (SteamAPI_Init())
#endif {
SteamUGCDetails_t Details;
OnFailure.Broadcast(FBPSteamWorkshopItemDetails()); if (SteamUGC()->GetQueryUGCResult(pResult->m_handle, 0, &Details))
} {
//if (SteamSubsystem != nullptr)
{
//SteamSubsystem->ExecuteNextTick([Details, this]()
//{
OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details));
//});
}
//OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details));
return;
}
}
else
{
//if (SteamSubsystem != nullptr)
{
//SteamSubsystem->ExecuteNextTick([this]()
//{
OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
//});
}
}
// Not needed, should never hit here
//OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
}
#endif

View File

@@ -1,19 +1,19 @@
Copyright Joshua Statzer Copyright Joshua Statzer
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.

View File

@@ -1 +1,7 @@
Readme and documentation will be worked on soon ### How do I use it? ###
**KantanDocGen Automatic Documentation ([KantanDocGen](http://kantandev.com/free/kantan-doc-gen))**
**[AdvancedSessions](https://vreue4.com/generated-node-documentation?section=advanced-sessions-plugin)**
**[AdvancedSteamSessions](https://vreue4.com/generated-node-documentation?section=advanced-steam-sessions-plugin)**