Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
JWT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kis_intern1
JWT
Commits
99e18c1e
Commit
99e18c1e
authored
Aug 01, 2023
by
nk161690
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
elastic
parent
06080c39
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
8 deletions
+48
-8
APIs/.vs/EOS_Teacher/DesignTimeBuild/.dtbcache.v2
APIs/.vs/EOS_Teacher/DesignTimeBuild/.dtbcache.v2
+0
-0
APIs/.vs/EOS_Teacher/v17/.futdcache.v2
APIs/.vs/EOS_Teacher/v17/.futdcache.v2
+0
-0
APIs/.vs/EOS_Teacher/v17/.suo
APIs/.vs/EOS_Teacher/v17/.suo
+0
-0
APIs/.vs/ProjectEvaluation/eos_teacher.metadata.v6.1
APIs/.vs/ProjectEvaluation/eos_teacher.metadata.v6.1
+0
-0
APIs/.vs/ProjectEvaluation/eos_teacher.projects.v6.1
APIs/.vs/ProjectEvaluation/eos_teacher.projects.v6.1
+0
-0
UnityProject/Assets/Login.cs
UnityProject/Assets/Login.cs
+46
-6
UnityProject/Assets/Photon/PhotonUnityNetworking/Resources/PhotonServerSettings.asset
...hotonUnityNetworking/Resources/PhotonServerSettings.asset
+2
-2
No files found.
APIs/.vs/EOS_Teacher/DesignTimeBuild/.dtbcache.v2
View file @
99e18c1e
No preview for this file type
APIs/.vs/EOS_Teacher/v17/.futdcache.v2
View file @
99e18c1e
No preview for this file type
APIs/.vs/EOS_Teacher/v17/.suo
View file @
99e18c1e
No preview for this file type
APIs/.vs/ProjectEvaluation/eos_teacher.metadata.v6.1
View file @
99e18c1e
No preview for this file type
APIs/.vs/ProjectEvaluation/eos_teacher.projects.v6.1
View file @
99e18c1e
No preview for this file type
UnityProject/Assets/Login.cs
View file @
99e18c1e
...
@@ -2,14 +2,11 @@ using System.Net.Http;
...
@@ -2,14 +2,11 @@ using System.Net.Http;
using
TMPro
;
using
TMPro
;
using
UnityEngine
;
using
UnityEngine
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json
;
using
System.Collections.Generic
;
using
Photon.Realtime
;
using
Photon.Realtime
;
using
Photon.Pun
;
using
Photon.Pun
;
using
UnityEngine.Networking
;
using
ExitGames.Client.Photon
;
using
System.Text
;
using
System.Text
;
using
Unity.VisualScripting.Antlr3.Runtime
;
using
System
;
using
UnityEditor.PackageManager
;
using
System.Net.Http.Headers
;
public
class
Login
:
MonoBehaviourPunCallbacks
public
class
Login
:
MonoBehaviourPunCallbacks
{
{
...
@@ -19,7 +16,6 @@ public class Login : MonoBehaviourPunCallbacks
...
@@ -19,7 +16,6 @@ public class Login : MonoBehaviourPunCallbacks
private
readonly
string
baseURL
=
"http://localhost:5172/User/"
;
private
readonly
string
baseURL
=
"http://localhost:5172/User/"
;
[
System
.
Serializable
]
public
class
RespondMessage
public
class
RespondMessage
{
{
public
bool
Success
{
get
;
set
;
}
public
bool
Success
{
get
;
set
;
}
...
@@ -27,6 +23,13 @@ public class Login : MonoBehaviourPunCallbacks
...
@@ -27,6 +23,13 @@ public class Login : MonoBehaviourPunCallbacks
public
string
Data
{
get
;
set
;
}
public
string
Data
{
get
;
set
;
}
}
}
public
class
LoginSession
{
public
string
Username
{
get
;
set
;
}
public
DateTime
LoginTime
{
get
;
set
;
}
public
DateTime
?
LogoutTime
{
get
;
set
;
}
}
public
async
void
CallLoginAPI
()
public
async
void
CallLoginAPI
()
{
{
string
endpoint
=
"Login"
;
string
endpoint
=
"Login"
;
...
@@ -50,6 +53,7 @@ public class Login : MonoBehaviourPunCallbacks
...
@@ -50,6 +53,7 @@ public class Login : MonoBehaviourPunCallbacks
//ThjMGQtYjU4ZTAyN2UyMmE4IiwibmJmIjoxNjkwNDUzMTc3LCJleHAiOjE2OTA0NTQ5NzcsImlhdCI6MTY5MDQ1MzE3N30
//ThjMGQtYjU4ZTAyN2UyMmE4IiwibmJmIjoxNjkwNDUzMTc3LCJleHAiOjE2OTA0NTQ5NzcsImlhdCI6MTY5MDQ1MzE3N30
//.W-0PXJ9GAmwOOXlKi8cEr3lBkwx9rGbpLKCCUYJkyCA");
//.W-0PXJ9GAmwOOXlKi8cEr3lBkwx9rGbpLKCCUYJkyCA");
AuthenticateWithPhoton
(
respondMessage
.
Data
);
AuthenticateWithPhoton
(
respondMessage
.
Data
);
LogLoginSession
(
respondMessage
.
Data
);
}
}
else
else
{
{
...
@@ -106,4 +110,40 @@ public class Login : MonoBehaviourPunCallbacks
...
@@ -106,4 +110,40 @@ public class Login : MonoBehaviourPunCallbacks
base
.
OnDisconnected
(
cause
);
base
.
OnDisconnected
(
cause
);
Debug
.
Log
(
"Disconnected from Photon. Reason: "
+
cause
.
ToString
());
Debug
.
Log
(
"Disconnected from Photon. Reason: "
+
cause
.
ToString
());
}
}
private
async
void
LogLoginSession
(
string
token
)
{
// Prepare the login session data
LoginSession
session
=
new
LoginSession
{
Username
=
CleanInput
(
username
.
text
.
Trim
()),
LoginTime
=
DateTime
.
UtcNow
,
LogoutTime
=
null
};
// Serialize the data as JSON
string
jsonData
=
JsonConvert
.
SerializeObject
(
session
);
// Send the data to Elasticsearch using HTTP POST request
string
elasticUrl
=
"https://893485fbcebc4a4d9102091b2bad74a4.us-central1.gcp.cloud.es.io:443/login_sessions/_doc"
+
"?pipeline=ent-search-generic-ingestion"
;
using
(
HttpClient
client
=
new
HttpClient
())
{
var
contentType
=
new
MediaTypeWithQualityHeaderValue
(
"application/json"
);
client
.
DefaultRequestHeaders
.
Accept
.
Add
(
contentType
);
client
.
DefaultRequestHeaders
.
Authorization
=
new
AuthenticationHeaderValue
(
"ApiKey"
,
"MUdvM3NJa0I3bFF0X01wcFZWY2s6MzU4WllreVJRSldfZEhWSTVPbHZ1UQ=="
);
HttpContent
content
=
new
StringContent
(
jsonData
,
Encoding
.
UTF8
,
"application/json"
);
HttpResponseMessage
response
=
await
client
.
PostAsync
(
elasticUrl
,
content
);
if
(
response
.
IsSuccessStatusCode
)
{
Debug
.
Log
(
"Login session logged successfully!"
);
}
else
{
Debug
.
LogError
(
"Failed to log login session to Elasticsearch. Error: "
+
response
.
StatusCode
);
}
}
}
}
}
UnityProject/Assets/Photon/PhotonUnityNetworking/Resources/PhotonServerSettings.asset
View file @
99e18c1e
...
@@ -28,7 +28,7 @@ MonoBehaviour:
...
@@ -28,7 +28,7 @@ MonoBehaviour:
AuthMode
:
0
AuthMode
:
0
EnableLobbyStatistics
:
0
EnableLobbyStatistics
:
0
NetworkLogging
:
1
NetworkLogging
:
1
DevRegion
:
DevRegion
:
asia
PunLogging
:
0
PunLogging
:
0
EnableSupportLogger
:
0
EnableSupportLogger
:
0
RunInBackground
:
1
RunInBackground
:
1
...
@@ -41,4 +41,4 @@ MonoBehaviour:
...
@@ -41,4 +41,4 @@ MonoBehaviour:
-
RespawnSpaceship
-
RespawnSpaceship
DisableAutoOpenWizard
:
1
DisableAutoOpenWizard
:
1
ShowSettings
:
0
ShowSettings
:
0
DevRegionSetOnce
:
0
DevRegionSetOnce
:
1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment