Commit fa2acf1b authored by nk161690's avatar nk161690

Elastic console

Test log session lên Elasticsearch trên localhost
parent 51c824b8
using Newtonsoft.Json; using Newtonsoft.Json;
using System;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
...@@ -20,12 +19,13 @@ public static class Log ...@@ -20,12 +19,13 @@ public static class Log
string jsonData = JsonConvert.SerializeObject(session); string jsonData = JsonConvert.SerializeObject(session);
// Send the data to Elasticsearch using HTTP POST request // 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()) using (HttpClient client = new HttpClient())
{ {
var contentType = new MediaTypeWithQualityHeaderValue("application/json"); var contentType = new MediaTypeWithQualityHeaderValue("application/json");
client.DefaultRequestHeaders.Accept.Add(contentType); 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"); HttpContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(elasticUrl, content); HttpResponseMessage response = await client.PostAsync(elasticUrl, content);
......
...@@ -11,6 +11,7 @@ public class PhotonServer : MonoBehaviourPunCallbacks ...@@ -11,6 +11,7 @@ public class PhotonServer : MonoBehaviourPunCallbacks
{ {
base.OnConnectedToMaster(); base.OnConnectedToMaster();
Debug.Log("Connected to Photon!"); Debug.Log("Connected to Photon!");
UserSessionManager.LogIn(PhotonNetwork.LocalPlayer.UserId);
message.text = "Login successful!<br>Connected to Photon."; message.text = "Login successful!<br>Connected to Photon.";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment