public static void SqlTrigger() { var context = SqlContext.TriggerContext; if (context == null || context.TriggerAction != TriggerAction.Insert) { return; } using ( var con = new SqlConnection(" context connection=true")) { con.Open(); using (var cmd = new SqlCommand("SELECT Name FROM INSERTED", con)) { using (var reader = cmd.ExecuteReader()) { var pipe = SqlContext.Pipe; if (pipe == null) { return; } while (reader.Read()) { pipe.Send(reader[0].ToString()); var sender = new SocketSender(); sender.MessageReceived += (o, message) => pipe.Send(message); sender.Send(reader[0].ToString()); } } } } }
void OnEnable() { SocketReceiver.OnLeftRoom += OnLeftRoom; SocketReceiver.OnGotPlayerList += OnGotPlayerList; SocketReceiver.OnRoomReady += OnRoomReady; SocketSender.Send("GetPlayerList", SocketLobby.Room.roomID); }
void Start() { connectButton.onClick.AddListener(() => { connectButton.interactable = false; SocketLobby.Instance.SetGameServerUrl(serverInput.text); SocketSender.Send("Connect", SocketLobby.Instance.settings.gameServerUrl); }); }
void UpdatePlayer() { UpdatePlayerData updatePlayerData = new UpdatePlayerData(); updatePlayerData.roomID = SocketLobby.Room.roomID; updatePlayerData.player = player; SocketLobby.Instance.SetPlayer(player); SocketSender.Send("UpdatePlayer", JsonUtility.ToJson(updatePlayerData)); }
void Start() { roomName.text = SocketLobby.Room.roomName; leaveRoomButton.onClick.AddListener(() => { leaveRoomButton.interactable = false; leaveRoomLoading.SetActive(true); SocketSender.Send("LeaveRoom", SocketLobby.Room.roomID); }); }
private static void Main() { var sender = new SocketSender(); sender.Error += Sender_Error; sender.MessageReceived += Sender_MessageReceived; while (true) { Console.Write("Message: "); var message = Console.ReadLine(); sender.Send(message); } }
IEnumerator CountDown() { for (int i = countdown - 1; i > 0; i--) { yield return(new WaitForSeconds(1f)); startGameCountDownText.text = i.ToString(); } yield return(new WaitForSeconds(1f)); SocketSender.Send("StartGame", SocketLobby.Room.roomID); }
public void SetRoom(RoomData room) { this.room = room; roomName.text = room.roomName; roomPlayers.text = room.playerCount.ToString() + "/" + SocketLobby.Instance.settings.maxPlayersPerRoom.ToString(); joinRoomButton.onClick.AddListener(() => { joinRoomButton.interactable = false; transform.parent.parent.GetComponent <LobbyPanel>().joinRoomLoading.SetActive(true); SocketSender.Send("JoinRoom", room.roomID); }); }
public void TestSocketSender() { SocketSender _sender = new SocketSender(this.ServerHost, this.ServerPort, this.SocketTimeout); var _data = _sender.Send(Encoding.Default.GetBytes(this.Send)); if (_data != null && _data.Length > 0) { this.ResponseReceived = Encoding.Default.GetString(_data); } bool _result = ManualResetEvent.WaitOne(this.SocketTimeout); _sender = null; Assert.AreEqual(true, _result, "Listener接收socket超时"); Assert.AreEqual(this.Send, this.SendReceived, string.Format("Client发送内容:{0},Listener监听到内容:{1}", this.Send, this.SendReceived)); Assert.AreEqual(this.Response, this.ResponseReceived, string.Format("Listener响应内容:{0},Client接收到响应:{1}", this.Response, this.ResponseReceived)); }
private void SendReceive(Socket client) { ISocketReceiver <string> _receiver = new SocketReceiver(_client, 1024, 128); ISocketSender <string> _sender = new SocketSender(_client); while (true) { if (client != null && !client.Connected) { break; } else if (client != null && client.Connected) { _sender.Send("", new ServerSenderAuthenticationLogic()); _receiver.Read(new ServerReceiverAuthenticationLogic()); } Thread.Sleep(1000); } }
void Start() { ui = GetComponent <SocketLobbyUI>(); ConfigData config = new ConfigData(); config.maxPlayersPerRoom = settings.maxPlayersPerRoom; config.minPlayerToStartGame = settings.minPlayersToStartGame; config.playerColors = settings.playerColors; config.defaultPlayerColor = settings.defaultPlayerColorIndex; SocketSender.Send("SetConfig", JsonUtility.ToJson(config)); ui.CreateTopPanel(); ui.CreateConnectPanel(); SocketReceiver.OnConnected += OnConnected; SocketReceiver.OnDisconnected += OnDisconnected; SocketReceiver.OnConnectionTimeout += OnConnectionTimeout; SocketReceiver.OnStartedGame += OnStartedGame; }
void Start() { roomNameInput.text = defaultRoomName; createRoomButton.onClick.AddListener(() => { roomNameInput.interactable = false; createRoomButton.interactable = false; createRoomLoading.SetActive(true); SocketSender.Send("CreateRoom", roomNameInput.text == "" ? defaultRoomName : roomNameInput.text); }); refreshButton.onClick.AddListener(() => { refreshButton.interactable = false; fetchRoomListLoading.SetActive(true); SocketSender.Send("GetRoomList"); }); fetchRoomListLoading.SetActive(true); SocketSender.Send("GetRoomList"); }
private void CmdSend_OnClick(object sender, RoutedEventArgs e) { var message = txtMain.Text; Task.Run(() => _sender.Send(message)); }