public void NetConnector_ParameterlessConstructor_ShouldReturnValidObject() { var connector = new NetConnector(); Assert.IsNotNull(connector, "Connector should be a valid object."); Assert.IsInstanceOf <INetConnector>(connector, "Connector should be a instance of {0}.", nameof(INetConnector)); }
public virtual void Connect(string user, string password, string token, [CallerMemberName] string caller = "") { Log("TRYING TO CONNECT - " + caller); var status = NetConnector.Status; switch (status) { case NetPeerStatus.NotRunning: NetConnector.Start(); Log("Networking Thread Started"); break; case NetPeerStatus.Starting: break; case NetPeerStatus.Running: break; case NetPeerStatus.ShutdownRequested: break; default: throw new ArgumentOutOfRangeException(); } var msg = NetConnector.CreateMessage(); msg.Write(user); msg.Write(password); ((ClientTripleDesNetEncryptor)NetEncryptor).EncryptHail(msg, token); NetConnector.Connect(_host, _port, msg); }
/// <summary> /// インスタンス生成:通信情報から生成 /// </summary> public static NetResponse Create(NetCommand cmd, NetConnector con) { var instance = new NetResponse(); instance.Command = cmd; if (con == null) { instance.IsConnectError = true; return(instance); } Debug.Log("[NetResponse] IsError = " + con.IsError.ToString() + (con.IsError ? "" : ", data size = " + con.WWW.bytes.Length.ToString())); if (con.IsError) { instance.IsConnectError = true; return(instance); } var result = instance.UnpackObject(con.ResponseData); if (result == null) { Debug.LogError("[NetResponse] Parse Error!! : " + cmd.ToString()); return(instance); } instance.ParseResultBase(result); // TODO : 結果をDumpしたいなどあれば追記. instance.ResultObjects = ParseResultObjects(result); return(instance); }
public async Task NetConnector_GetXmlAsString_WithValidParameters_ShouldWork(string url, string checkString) { var connector = new NetConnector(BaseAddress); var content = await connector.GetAsync(url, "application/xml"); Assert.IsTrue(content.Contains(checkString), "Content of the response should contain {0}", checkString); }
public void NetConnector_ConstructorWithValidBaseAddress_ShouldReturnValidObject(string baseAddress) { var connector = new NetConnector(baseAddress); Assert.IsNotNull(connector, "Connector should be a valid object."); Assert.IsInstanceOf <INetConnector>(connector, "Connector should be a instance of {0}.", nameof(INetConnector)); }
public override void Start() { if (_configuration.Host != "fake" && _configuration.Service != "fake" && _configuration.Port != 157) { _host = NetConnector.CreateServer <T>(this, _configuration); } }
protected virtual async void ConnectionApproval(NetIncomingMessage msg) { var connection = msg.SenderConnection; var user = ""; var password = ""; try { var token = msg.ReadString(); var tripleDesInformation = await Authenticator.GetKeyFromToken(token); ((ServerTripleDesNetEncryptor)NetEncryptor).ImportKeyForConnection(msg.SenderConnection, tripleDesInformation.Key, tripleDesInformation.Iv); ((ServerTripleDesNetEncryptor)NetEncryptor).Decrypt(msg); user = msg.ReadString().ToLower(); password = msg.ReadString(); } catch (Exception e) { Log(e); connection.Deny(NetConnectionResult.Unknown); NetConnector.Recycle(msg); return; } if (PendingAndLoggedInUsers.Values.Any(c => c.UserName == user)) { AuthenticationResults.Add(new Tuple <AuthenticationResult, string>( new AuthenticationResult() { Connection = connection, Success = false, RequestState = RequestState.UserAlreadyLoggedIn }, user)); return; } PendingAndLoggedInUsers.Add(connection, new CommunicationUser <TAuthenticationUser>() { UserName = user }); var authTask = Authenticator.Authenticate(user, password) .ContinueWith(async approval => { var authentication = await approval; authentication.Connection = connection; ConnectionApprovalExtras(authentication); if (authentication.Success && !string.IsNullOrEmpty(authentication.UserId)) { var userData = await GetUser(authentication.UserId); PendingAndLoggedInUsers[connection].UserData = userData; PendingAndLoggedInUsers[connection].LoggedInTime = DateTime.UtcNow; } AuthenticationResults.Add(new Tuple <AuthenticationResult, string>(authentication, user)); NetConnector.Recycle(msg); }); AddRunningTask(authTask); }
private ICommonNetReceiverWriterForWrite CreateChannel(string host, int port) { var factory = NetConnector.Connect <ICommonNetReceiverWriterForWrite>( new ServerId(host, port), Client.Support.Consts.WcfServiceName, new ConnectionTimeoutConfiguration(Consts.OpenTimeout, Consts.SendTimeout)); return(factory.CreateChannel()); }
public override void Tick(int interval) { NetIncomingMessage msg; while ((msg = NetConnector.ReadMessage()) != null) { switch (msg.MessageType) { case NetIncomingMessageType.VerboseDebugMessage: case NetIncomingMessageType.DebugMessage: case NetIncomingMessageType.WarningMessage: case NetIncomingMessageType.ErrorMessage: break; case NetIncomingMessageType.Error: break; case NetIncomingMessageType.StatusChanged: var change = (NetConnectionStatus)msg.ReadByte(); var connectionResult = (NetConnectionResult)msg.ReadByte(); OnConnectionStatusChanged(change, connectionResult, msg.SenderConnection); break; case NetIncomingMessageType.UnconnectedData: break; case NetIncomingMessageType.ConnectionApproval: break; case NetIncomingMessageType.Data: NetEncryptor.Decrypt(msg); FilterMessage(msg); break; case NetIncomingMessageType.Receipt: break; case NetIncomingMessageType.DiscoveryRequest: break; case NetIncomingMessageType.DiscoveryResponse: break; case NetIncomingMessageType.NatIntroductionSuccess: break; case NetIncomingMessageType.ConnectionLatencyUpdated: break; default: Console.WriteLine("Unhandled type: " + msg.MessageType); break; } NetConnector.Recycle(msg); } RunTasks(); Task.Delay(interval).Wait(); }
protected SingleConnection(ServerId server, ConnectionConfiguration configuration, ConnectionTimeoutConfiguration timeoutConfiguration) { Server = server; _bPool = new StableElementsDynamicConnectionPool <T>( NetConnector.Connect <T>(Server, configuration.ServiceName, timeoutConfiguration), -1, configuration.MaxElementCount); }
protected override void Dispose(bool isUserCall) { if (isUserCall && _host != null) { NetConnector.StopService(_host); } base.Dispose(isUserCall); }
public void NetConnector_ConstructorWithInvalidBaseAddress_ShouldThrowUriFormatException(string baseAddress) { Assert.Catch <UriFormatException>( () => { var connector = new NetConnector(baseAddress); }, "Constructor should throw UriFormatException"); }
public void NetConnector_ConstructorWithNullOrWhiteSpaceBaseAddress_ShouldThrowArgumentNullException(string baseAddress) { Assert.Catch <ArgumentNullException>( () => { var connector = new NetConnector(baseAddress); }, "Constructor With Null BaseAddress should throw {0}", nameof(ArgumentNullException)); }
public async Task NetConnector_GetDeserializedXml_WithValidParameters_ShouldWork(string url, int id, string name, string category, decimal price) { var connector = new NetConnector(BaseAddress); var responseObject = await connector.GetXmlObjectAsync <Product>(url); Assert.IsNotNull(responseObject, "Response object should not be null."); Assert.AreEqual(id, responseObject.Id, "Id should match."); Assert.AreEqual(name, responseObject.Name, "Name should match."); Assert.AreEqual(category, responseObject.Category, "Category should match."); Assert.AreEqual(price, responseObject.Price, "Price should match."); }
public void NetConnector_ConstructorWithNullOrWhiteSpaceBaseAddress_ShouldThrowArgumentNullExceptionWithCorrectParamName(string baseAddress) { try { var connector = new NetConnector(baseAddress); } catch (ArgumentNullException e) { Assert.AreEqual("BaseAddress", e.ParamName, "ParamName should be BaseAddress"); } }
public async Task NetConnector_GetDeserializedJsonArray_WithValidParameters_ShouldWork(string url, int numberOfItems) { var connector = new NetConnector(BaseAddress); var responseObject = await connector.GetJsonObjectAsync <Product[]>(url); Assert.IsNotNull(responseObject, "Response object should not be null."); Assert.AreEqual(numberOfItems, responseObject.Length, "Number of items should match."); for (int i = 0; i < numberOfItems; ++i) { Assert.AreEqual(i + 1, responseObject[i].Id, "Id should be {0}.", i + 1); } }
/// 通信処理終了時に呼ばれるメソッド private void DidLoad(NetConnector con) { // 通信終了イベント後を1つの通信終了とする. if (this.DidEnd == null) { this.DidLoadEndProc(con); con.Dispose(); } else { // 通信終了イベントが設定されている場合、ながく終了デリゲートが呼ばれない場合がある。終了デリゲートが返って来るまでは次以降に来る結果を遅延しとく. m_endEventWaitList.Enqueue(con); } }
private void DidLoadEndProc(NetConnector con) { if (con == null) { Debug.LogError("[NetConnectManager] Error!! DidLoadEndProc : NetConnector is null."); return; } if (con.Info.DidLoadDelegate != null) { con.Info.DidLoadDelegate(con); } m_canConnectCnt++; if (m_canConnectCnt > this.MAX_CONNET_COUNT) { m_canConnectCnt = this.MAX_CONNET_COUNT; } }
public async Task NetConnector_PostAndDeserializeDictionaryAsXml_WithValidParameters_ShouldWork(string url, string name, string category, decimal price) { var connector = new NetConnector(BaseAddress); var values = new Dictionary <string, string> { { "name", name }, { "category", category }, { "price", price.ToString() } }; var responseObject = await connector.PostXmlObjectAsync <Product>(url, values, Encoding.UTF8); Assert.IsNotNull(responseObject, "Response should not be null."); Assert.AreEqual(name, responseObject.Name, "Name should match."); Assert.AreEqual(category, responseObject.Category, "Category should match."); Assert.AreEqual(price, responseObject.Price, "Price should match."); }
public async Task NetConnector_PostDictionary_WithValidParameters_ShouldWork(string url, string name, string category, decimal price) { var connector = new NetConnector(BaseAddress); var values = new Dictionary <string, string> { { "name", name }, { "category", category }, { "price", price.ToString() } }; var response = await connector.PostAsync(url, values, Encoding.UTF8); Assert.IsNotNull(response, "Response should not be null."); Assert.IsTrue(response.Contains(name), "Response should contain the name."); Assert.IsTrue(response.Contains(category), "Response should contain the category."); Assert.IsTrue(response.Contains(price.ToString()), "Response should contain the price."); }
/// 更新処理:通信終了イベント待ちキュー private void UpdateEndEventWaitList() { if (m_bNowEndEventWait || m_endEventWaitList.Count <= 0) { return; } m_bNowEndEventWait = true; NetConnector con = m_endEventWaitList.Dequeue(); this.DidEnd(con, delegate { this.DidLoadEndProc(con); con.Dispose(); m_bNowEndEventWait = false; }); }
void Start() { gameObject.transform.localPosition = new Vector3(0.0f, 25.0f, 0.0f); //GameObject.Find("OnlineCanvas/LodingImage").SetActive(false); なにこれ1 // アニメーション情報の取得 animator = GetComponent <Animator>(); // プレイヤーオブジェクト法線の初期化 playerNormal = new Vector3(0.0f, 1.0f, 0.0f); // プレイヤー位置の地面の法線の初期化 surfaceNormal = transform.localPosition - Vector3.zero; surfaceNormal = surfaceNormal.normalized; // プレイヤー進行方向の初期化 dirVec = new Vector3(0.0f, 0.0f, 1.0f); // プレイヤー移動量ベクトルの初期化 moveVec = Vector3.zero; // 球面中心点からプレイヤーまでの距離 radPlayer = Mathf.Sqrt( transform.position.x * transform.position.x + transform.position.y * transform.position.y + transform.position.z * transform.position.z); //コントロールマネージャの取得 controllerManager = GameObject.Find("PuniconCamera/ControllerManager").GetComponent <Scr_ControllerManager>(); prePosition = transform.position; cam = GameObject.Find("PlayerCamera").GetComponent <Camera>(); NetConnector netConnector = GameObject.Find("NetConnector").GetComponent <NetConnector>(); //Offline時のときは位置、回転の同期スクリプトを無効にする if (!isLocalPlayer) { gameObject.GetComponent <PlayerSyncPosition>().enabled = true; gameObject.GetComponent <PlayerSyncRotation>().enabled = true; } }
public async Task NetConnector_PostString_WithValidParameters_ShouldWork(string url, string name, string category, decimal price) { var product = new Product { Name = name, Category = category, Price = price }; string content = JsonConvert.SerializeObject(product); var connector = new NetConnector(BaseAddress); var response = await connector.PostAsync(url, content, "application/json", Encoding.UTF8); Assert.IsNotNull(response, "Response should not be null."); Assert.IsTrue(response.Contains(name), "Response should contain the name."); Assert.IsTrue(response.Contains(category), "Response should contain the category."); Assert.IsTrue(response.Contains(price.ToString()), "Response should contain the price."); Console.WriteLine(content); Console.WriteLine(response); }
NetworkMissionManager missionManager; //ミッションマネージャ // Use this for initialization void Start() { SyncbGoal = false; //__________デバッグ用にキネマティック解除 GetComponent <Rigidbody>().isKinematic = false; //スポーンしたオブジェクトをMissionObject階層へ移動させる。 GameObject parent = GameObject.Find("NetworkMissionManager/NetworkTransportation/MissionObject"); transform.parent = parent.transform; if (transportNum < 1) { transportNum = 1; } if (isServer) { ServerStart(); } //NetConnectorの取得 GameObject netcon = GameObject.Find("NetConnector"); if (null != netcon) { netConnector = netcon.GetComponent <NetConnector> (); } //MissionManagerの取得 GameObject manager = GameObject.Find("NetworkMissionManager"); if (null != manager) { missionManager = manager.GetComponent <NetworkMissionManager> (); } }
public Promotion(NetConnector _cntr) { cntr = _cntr; charas = new List <Chara>(); isClient = cntr.Type == StartType.Client; }
public WorldServer(string publicIP, int port) { server = new NetConnector(port); PublicIP = publicIP; Port = port; }
public override void CloseConnection() { NetConnector.Connections.FirstOrDefault()?.Disconnect(); NetConnector.Shutdown("shutdown"); }
public PortController() { Connector = new NetConnector(); }
public LoginServer(int port) { server = new NetConnector(port); }
// Use this for initialization void Start() { //自分が操作するオブジェクトに限定する if (isLocalPlayer) { //自分のプレイヤーの名前変更 //name = GameObject.Find("CharactorInfo").GetComponent<CharactorInfo>().GetPlayerName(); //name = "Player"; //自分を操作するぷにコンに自分自身を伝える。 PunipuniController punipuni = GameObject.Find("PuniconCamera/Punicon").GetComponent <PunipuniController>(); punipuni.SetPlayer(this.gameObject); //ローディングイメージのアクティブを切る if (GameObject.Find("OnlineCanvas/LoadingImage") != null) { GameObject.Find("OnlineCanvas/LoadingImage").SetActive(false); } //PlayerCameraを使うため、Scene Cameraを非アクティブ化 GameObject cam = GameObject.Find("Scene Camera"); if (null != cam) { cam.SetActive(false); } //Camera,AudioListenerの各コンポーネントをアクティブ化 PlayerCamera.GetComponent <Camera>().enabled = true; audioListener.GetComponent <AudioListener>().enabled = true; //LocalPlayerのAnimatorパラメータを自動的に送る GetComponent <NetworkAnimator>().SetParameterAutoSend(0, true); //カメラの取得等があるため、ここでPostureControllerのスクリプトをOnにしてStartメソッド呼び出し。 GetComponent <OfflinePostureController>().enabled = true; //ミッションマネージャに自分がスポーンした事を知らせる。 GameObject.Find("NetworkMissionManager").GetComponent <NetworkMissionManager>().SetPlayer(this.gameObject); netConnector = GameObject.Find("NetConnector").GetComponent <NetConnector>(); if (null != netConnector) { netConnector.SetLocalPlayer(gameObject); } charaInfo = GameObject.Find("CharactorInfo").GetComponent <CharactorInfo>(); if (null != charaInfo) { // SendName(charaInfo.GetPlayerName()); //playerName.SetNameText(charaInfo.GetPlayerName()); useChara = charaInfo.GetCharaSelectData(); } skyBg.gameObject.SetActive(true); //接続時のローディングイメージを有効 // GameObject.Find("OnlineCanvas/LoadingImage").SetActive(false); netConnector.createPlayer = true; } else { //自分以外の移動スクリプトを切る GetComponent <OfflinePostureController>().enabled = false; PlayerCamera.GetComponent <Camera>().enabled = false; audioListener.GetComponent <AudioListener>().enabled = false; skyBg.gameObject.SetActive(false); } }