static void Main(string[] args) { TcpClient client = null; NetworkStream stream = null; Logger logger = new Logger(); try { client = new TcpClient("127.0.0.1", 5001); stream = client.GetStream(); do { var input = GetWords(); Messager.Send(stream, new { words = input }); var answer = Messager.Recive(stream); Console.WriteLine(answer); } while (WantToContinue()); Messager.Send(stream, new { stop = true }); } catch (Exception e) { logger.Log(e.Message); } finally { client?.Close(); stream?.Close(); } }
public void Handle() { NetworkStream stream = null; try { stream = _client.GetStream(); while (true) { dynamic request = Messager.Recive(stream); _logger.Log($"Was recived mesage : {request}"); if (request["stop"] == true) { return; } var words = JsonConvert.DeserializeObject <string[]>(request["words"].ToString()); var files = _index[words]; var answer = new { files }; var jsonAnswer = Messager.Send(stream, answer); _logger.Log($"Was sended answer : {jsonAnswer}"); } } catch (JsonException e) { var answer = new { error = "Invalid body" }; Messager.Send(stream, answer); _logger.Log(e.Message); } finally { stream?.Close(); _client?.Close(); _logger.Log("Client disconected"); } }
private void OnButtonTwoClick() { var user = new User { Number = "4", Name = "小黑", Remark = "ViewModel发送给View" }; Messager.Send(this, new Message <User>("ViewModelToView", user)); }
private void ButtonFour_OnClick(object sender, RoutedEventArgs e) { //消息发送 var user = new User { Number = "5", Name = "小灰", Remark = "View发送给ViewModel" }; Messager.Send(this, new Message <User>("ViewToViewModel", user)); }
public void SetValue(string name, int value, bool sendMessage = true) { m_GameSaveManger.SetInt(name, GameSaveManager.Location.System, value); if (sendMessage) { Messager.Send(OnSettingChangedMessage); } }
private void Start() { m_GameSaveManger = Get <GameSaveManager>(); foreach (var setting in defaultSettings) { SetValue(setting.name, setting.defaultValue, false); } Messager.Send(OnSettingChangedMessage); }
public void Execute(string[] args) { if (args.Length > 0) { string full = args.Aggregate((i, j) => i + " " + j); Messager.Send(full); } else { Console.Console.Log(name, help, LogType.Warning); } }
public override void Execute(GameObject instigator = null) { switch (messageType) { case MessageType.GameLevelStart: Messager.Send(GameManager.GameLevelStartMessage); break; case MessageType.MainMenuStart: Messager.Send(GameManager.MainMenuStartMessage); break; } }
public override void OnBehaviourPlay(Playable playable, FrameData info) { base.OnBehaviourPlay(playable, info); if (StartMessage != string.Empty) { if (Application.isPlaying) { Messager.Send(StartMessage, Instigator); } else { Debug.Log($"[SendMessageBehaviour] BroadcastMessage를 보냈습니다 : '{StartMessage}'"); } } }
public override void OnBehaviourPlay(Playable playable, FrameData info) { base.OnBehaviourPlay(playable, info); if (StartMessage != "") { if (Application.isPlaying) { Messager.Send(StartMessage, Instigator); } else { Debug.Log("[SendMessageBehaviour] Would have sent broadcast message : '" + StartMessage + "'"); } } }
private static void PlayFromHere_OnPlayFromHere(Vector3 position, Vector3 forward) { // Get the FirstPersonCharacter prefab in Resources and instantiate it var prefab = (GameObject)Resources.Load("PlayFromHere-FirstPersonCharacter"); var player = GameObject.Instantiate(prefab); player.name = "(Play from Here) " + prefab.name; // position the character correctly, so the current POV matches the player's height var controller = player.GetComponent <GameplayIngredients.Controllers.FirstPersonController>(); player.transform.position = new Vector3(position.x, position.y - controller.PlayerHeight, position.z); // orient the player correctly var orient = forward; orient.Scale(new Vector3(1, 0, 1)); player.transform.forward = orient; Messager.Send("PLAY_FROM_HERE"); }
private void updateFever() { if (isFeverMode) { if (FeverTime > 0f) //피버 모드면 시간을 계속 감속시킵니다. { FeverTime -= Time.deltaTime; } else { //플레이어 속도를 원래대로 되돌립니다. Messager.Send("NormalSpeed"); //음악의 속도 파라미터를 다시 0으로 되돌립니다. Get <AudioManager>().bgm.setParameterByName("Fast", 0); //피버모드 초기화 FeverTime = 0f; isFeverMode = false; } } }
private void RadContextMenu_OnOpening(object sender, RadRoutedEventArgs e) { Messager.Send(this, new Message <RadRoutedEventArgs>("MenuOpening", e)); }
public override void Execute() { Messager.Send(MessageToSend); }
private void ButtonThree_OnClick(object sender, RoutedEventArgs e) { //消息发送 Messager.Send(this, new Message <string>("ViewToViewModel", "你好!")); }
public override void OnVFXOutputEvent(VFXEventAttribute eventAttribute) { Messager.Send(message, gameObject); }
private void OnButtonOneClick() { Messager.Send(this, new Message <string>("ViewModelToView", "你好!")); }
static void messager_IncomingConnectionEstablished(Messager<SessionData> sender, Session<SessionData> e) { Console.WriteLine("New Connection, Time = {0}, EndPoint = {1}", e.BeginTime, e.EndPoint); e.Data.Messager = new TcpMessager<SessionData2>(); e.Data.Messager.DataReceived += (m, conn, data) => { sender.Send(e, data); }; e.Data.Messager.SendError += Messager_SendError; e.Data.Messager.SessionEnded += (m, conn) => { Console.WriteLine("Connection Closed"); e.Data.Messager = null; e.Close(); }; e.Data.Messager.Connect(new IPEndPoint(System.Net.IPAddress.Parse("121.201.7.41"), 80), (m, conn, ex) => { if (conn != null) { e.Data.Connection = conn; lock (e.Data) { if (e.Data.Buffer != null) { conn.Send(new ArraySegment<byte>(e.Data.Buffer, 0, e.Data.Buffer.Length)); } } } }); }
public override void Execute(GameObject instigator = null) { Messager.Send(MessageToSend, instigator); }