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
fa2acf1b
Commit
fa2acf1b
authored
Aug 11, 2023
by
nk161690
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Elastic console
Test log session lên Elasticsearch trên localhost
parent
51c824b8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
3 deletions
+4
-3
UnityProject/Assets/Log.cs
UnityProject/Assets/Log.cs
+3
-3
UnityProject/Assets/PhotonServer.cs
UnityProject/Assets/PhotonServer.cs
+1
-0
No files found.
UnityProject/Assets/Log.cs
View file @
fa2acf1b
using
Newtonsoft.Json
;
using
System
;
using
System.Net.Http.Headers
;
using
System.Net.Http
;
using
System.Text
;
...
...
@@ -20,12 +19,13 @@ public static class Log
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"
;
//string elasticUrl = "https://893485fbcebc4a4d9102091b2bad74a4.us-central1.gcp.cloud.es.io:443/login_sessions/_doc?pipeline=ent-search-generic-ingestion";
string
elasticUrl
=
"http://localhost:9200/session_login/_doc"
;
using
(
HttpClient
client
=
new
HttpClient
())
{
var
contentType
=
new
MediaTypeWithQualityHeaderValue
(
"application/json"
);
client
.
DefaultRequestHeaders
.
Accept
.
Add
(
contentType
);
client
.
DefaultRequestHeaders
.
Authorization
=
new
AuthenticationHeaderValue
(
"ApiKey"
,
"b1VSTjNva0J1TEFPdkJiaTJPQ186aklvdHd0c1hUT1dkbkFBTEU4M1NtQQ=="
);
//
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("ApiKey", "b1VSTjNva0J1TEFPdkJiaTJPQ186aklvdHd0c1hUT1dkbkFBTEU4M1NtQQ==");
HttpContent
content
=
new
StringContent
(
jsonData
,
Encoding
.
UTF8
,
"application/json"
);
HttpResponseMessage
response
=
await
client
.
PostAsync
(
elasticUrl
,
content
);
...
...
UnityProject/Assets/PhotonServer.cs
View file @
fa2acf1b
...
...
@@ -11,6 +11,7 @@ public class PhotonServer : MonoBehaviourPunCallbacks
{
base
.
OnConnectedToMaster
();
Debug
.
Log
(
"Connected to Photon!"
);
UserSessionManager
.
LogIn
(
PhotonNetwork
.
LocalPlayer
.
UserId
);
message
.
text
=
"Login successful!<br>Connected to Photon."
;
}
...
...
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