private bool SendData(SocketCommand CommandObjectToSend, AsyncSkt ConnectionToUse) { // do we have a valid connection? if (ConnectionToUse == null) { return(false); } // do we have an object to send? if (CommandObjectToSend == null) { return(false); } string SerializedData = ""; SerializedData = TcpIpCommon.SerializeCommandObject(CommandObjectToSend); // (bsk) add divider for splitting... SerializedData += "<msg>"; try { ConnectionToUse.SendData(SerializedData); } catch (Exception ex) { //LogAccess.WriteLog("Error sending data: " + ex.ToString(), "Listener"); //throw; } return(true); }
private bool SendData(string xmlToSend, AsyncSkt ConnectionToUse) { // do we have a valid connection? if (ConnectionToUse == null) { return(false); } // do we have an object to send? if (string.IsNullOrEmpty(xmlToSend)) { return(false); } try { ConnectionToUse.SendData(xmlToSend); } catch (Exception ex) { //LogAccess.WriteLog("Error sending data: " + ex.ToString(), "Talker"); } //LogAccess.WriteLog("SendData complete", "Talker"); return(true); }
private bool SendData(string dataString, AsyncSkt ConnectionToUse) { if (ConnectionToUse == null) { return(false); } // do we have an object to send? if (dataString == null) { return(false); } try { ConnectionToUse.SendData(dataString); } catch (Exception ex) { //LogAccess.WriteLog("Error sending data: " + ex.ToString(), "Listener"); //throw; } return(true); }
private void InitializeListener(string PortToListenOn = "") { if (PortToListenOn == "") { // if not Port passed in, use default PortToListenOn = ListeningPort; } try { //LogAccess.WriteLog("Initializing Listener...", "Listener"); } catch (Exception ex) { } _socketListener = new AsyncSkt(); // create callback delegates: _socketListener.ConnectionAccepted += new AsyncSkt.ConnectionAcceptedEventHandler(ProcessOnTalkerConnect); _socketListener.MsgReceived += new AsyncSkt.MsgReceivedEventHandler(ProcessOnDataArrival); _socketListener.SktError += new AsyncSkt.SktErrorEventHandler(ProcessError); //SocketConnection.SktError += new AsyncSkt.SktErrorEventHandler(SocketErrorHandler); _socketListener.Closed += ProcessOnDisconnect; Listen(PortToListenOn); }
private void InitializeTalker() { //LogAccess.WriteLog("Initializing Talker", "Talk"); _socketTalker = new AsyncSkt(); // create callback delegates: _socketTalker.Connected += new AsyncSkt.ConnectedEventHandler(ProcessOnConnect); }
private void InitializeListener() { //LogAccess.WriteLog("Initializing Listener", "Talker"); _socketListener = new AsyncSkt(); // create callback delegates: _socketListener.MsgReceived += new AsyncSkt.MsgReceivedEventHandler(ProcessOnDataArrival); _socketListener.ConnectionAccepted += new AsyncSkt.ConnectionAcceptedEventHandler(ProcessConnectionAccepted); _socketListener.SktError += new AsyncSkt.SktErrorEventHandler(ProcessError); }
// private routines private void SendHeartBeat(AsyncSkt SocketToSendOn) { SocketCommand myHeartBeat = new SocketCommand() { ID = TcpIpCommon.GetMyID(), Timestamp = DateTime.Now, Command = CommandType.Heartbeat }; //LogAccess.WriteLog("...heartbeat...", "Listener"); SendData(myHeartBeat, SocketToSendOn); }
// private routines private void SendHeartBeat(AsyncSkt SocketToSendOn) { //disable the heartbeat so we don't get queued events DisableHeartbeat(); // _heartbeatTimer.Enabled = false; SocketCommand myHeartBeat = new SocketCommand() { ID = TcpIpCommon.GetMyID(), Timestamp = DateTime.Now, //Command = CommandType.Heartbeat }; //LogAccess.WriteLog("...heartbeat...", "Talker"); SendData(myHeartBeat, SocketToSendOn); //re enable the timer so we can send future heartbeats EnableHeartbeat(); // _heartbeatTimer.Enabled = true; }
// public routines public void Connect(string DestinationIP, string DesitnationPort) { System.Net.IPAddress remoteConnection; remoteConnection = System.Net.IPAddress.Parse(DestinationIP); if (_socketTalker == null) { _socketTalker = new AsyncSkt(); } _socketTalker.RemoteIP = remoteConnection; _socketTalker.Port = Convert.ToInt32(TalkingPort); _socketTalker.PacketSize = 8192; //LogAccess.WriteLog("Connecting (port=" + TalkingPort + ")", "Listener"); _socketTalker.Connect(); }
public PacketManager() { packetParser = new VonRipper(VonRipper.PacketType.XCmp | VonRipper.PacketType.XRnd | VonRipper.PacketType.XBkt | VonRipper.PacketType.XRun | VonRipper.PacketType.XAnn | VonRipper.PacketType.XTrick | VonRipper.PacketType.XRac); ipClientToHelm = new AsyncSkt(); ipClientToHelm.EOL_Receive = ((char)3).ToString(); ipClientToHelm.EOL_Send = ((char)3).ToString(); ipClientToHelm.PacketSize = 16384; ipClientToHelm.SktEncoding = Encoding.Unicode; ipClientToHelm.MsgReceived += (x) => { packetParser.EnqueueIfRegistered(x); }; }
// Dispose(bool disposing) executes in two distinct scenarios. // If disposing equals true, the method has been called directly // or indirectly by a user's code. Managed and unmanaged resources // can be disposed. // If disposing equals false, the method has been called by the // runtime from inside the finalizer and you should not reference // other objects. Only unmanaged resources can be disposed. private void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this._disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { // Dispose managed resources. if (_heartbeatTimer != null) { _heartbeatTimer.Dispose(); } if (_socketTalker != null) { _socketTalker.Close(); _socketTalker = null; } } // Note disposing has been done. _disposed = true; } }
public Scoring(int judge) : base("Scoring", null) { //UserDefaultsHelper.LoadDefaultSettings (); //---- initialize our user settings, which loads them from the file (if they exist) //NSUserDefaults.StandardUserDefaults.Init (); judgeNum= judge; //judgeNum.Text = judgeNo.ToString(); //this.judgeNum.Text = judgeNumber.ToString(); currentID = 12345; ripper = new VonRipper(VonRipper.PacketType.XRun | VonRipper.PacketType.XBkt | VonRipper.PacketType.XCmp | VonRipper.PacketType.XRnd | VonRipper.PacketType.XHb | VonRipper.PacketType.XRac | VonRipper.PacketType.XBc | VonRipper.PacketType.XAnn); ripper.AnnouncementUpdate += new EventHandler(ripper_AnnouncementUpdate); ripper.BracketUpdate += new EventHandler(ripper_BracketUpdate); ripper.RunUpdate += new EventHandler(ripper_RunUpdate); ripper.HeartbeatUpdate += (x, y) => { XHeartbeat hb = x as XHeartbeat; currentMCID = hb.MCID; advCount = hb.AdvanceCount; InvokeOnMainThread(delegate { timeStamp = hb.TOD; this.heartBeat.Text = currentMCID + "-" + timeStamp; this.heartBeat.TextColor = new UIColor(random.Next(100, 255), random.Next(100, 255), random.Next(100, 255),1); }); }; client = new AsyncSkt(); client.EOL_Receive = ((char) 3).ToString(); client.EOL_Send = ((char) 3).ToString(); client.RemoteIP = IPAddress.Parse(NSUserDefaults.StandardUserDefaults.StringForKey ("helmip")); client.Port = NSUserDefaults.StandardUserDefaults.IntForKey("helmport"); client.PacketSize = 16384; client.SktEncoding = Encoding.Unicode; timer = new Timer(); timer.Interval = 5000f; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); #region Socket Events client.Connected += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Green; this.txtSktStatus.Text = "Connected"; SendJudgeID(); }); }; client.Closed += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Red; txtSktStatus.Text = "Connection Closed!"; }); timer.Start(); }; client.MsgReceived += (x) => { ripper.EnqueueIfRegistered(x); }; client.SktError += new AsyncSkt.SktErrorEventHandler(client_SktError); client.GeneralEx += (x) => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Red; txtSktStatus.Text = "G.Ex: " + x.ToString(); }); timer.Start(); }; client.ConnectionAccepted += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Green; txtSktStatus.Text = "Connection Accepted!"; }); }; #endregion client.Connect(); }
// private routines private void SendHeartBeat(AsyncSkt SocketToSendOn) { //disable the heartbeat so we don't get queued events DisableHeartbeat(); // _heartbeatTimer.Enabled = false; PlayerCommand myHeartBeat = new PlayerCommand() { ID = TcpIpCommon.GetMyID(), Timestamp = DateTime.Now, Command = CommandType.Heartbeat }; //LogAccess.WriteLog("...heartbeat...", "Talker"); SendData(myHeartBeat, SocketToSendOn); //re enable the timer so we can send future heartbeats EnableHeartbeat(); // _heartbeatTimer.Enabled = true; }
private bool SendData(string xmlToSend, AsyncSkt ConnectionToUse) { // do we have a valid connection? if (ConnectionToUse == null) { return false; } // do we have an object to send? if (string.IsNullOrEmpty(xmlToSend)) { return false; } try { ConnectionToUse.SendData(xmlToSend); } catch (Exception ex) { //LogAccess.WriteLog("Error sending data: " + ex.ToString(), "Talker"); } //LogAccess.WriteLog("SendData complete", "Talker"); return true; }
private bool SendData(PlayerCommand CommandObjectToSend, AsyncSkt ConnectionToUse) { // do we have a valid connection? if (ConnectionToUse == null) { return false; } // do we have an object to send? if (CommandObjectToSend == null) { return false; } string SerializedData = ""; try { SerializedData = TcpIpCommon.SerializeCommandObject(CommandObjectToSend); } catch (Exception ex) { //LogAccess.WriteLog("Error serializing data in SendData: " + ex.ToString(), "Talker"); } // (bsk) add divider for splitting... SerializedData += "<msg>"; try { ConnectionToUse.SendData(SerializedData); } catch (Exception ex) { //LogAccess.WriteLog("Error sending data: " + ex.ToString(), "Talker"); } //LogAccess.WriteLog("SendData complete", "Talker"); return true; }
public SplitScreen(int JudgeNo) : base("SplitScreen", null) { judgeNum = JudgeNo; currentAthOneID = 12345; currentAthTwoID = 12345; AthOne = true; ripper = new VonRipper(VonRipper.PacketType.XRun | VonRipper.PacketType.XBkt | VonRipper.PacketType.XCmp | VonRipper.PacketType.XRnd | VonRipper.PacketType.XHb | VonRipper.PacketType.XRac | VonRipper.PacketType.XBc | VonRipper.PacketType.XAnn); ripper.AnnouncementUpdate += new EventHandler(ripper_AnnouncementUpdate); ripper.BracketUpdate += new EventHandler(ripper_BracketUpdate); ripper.RunUpdate += new EventHandler(ripper_RunUpdate); ripper.HeartbeatUpdate += (x, y) => { XHeartbeat hb = x as XHeartbeat; currentMCID = hb.MCID; currentCOMPID = hb.CompID; currentBracketID = hb.BracketID.ToString(); currentRoundID = hb.RoundID.ToString(); InvokeOnMainThread(delegate { timeStamp = hb.TOD; this.heartBeat.Text = currentMCID + "-" + timeStamp; this.heartBeat.TextColor = new UIColor(random.Next(100, 255), random.Next(100, 255), random.Next(100, 255),1); }); }; client = new AsyncSkt(); client.EOL_Receive = ((char) 3).ToString(); client.EOL_Send = ((char) 3).ToString(); client.RemoteIP = IPAddress.Parse(NSUserDefaults.StandardUserDefaults.StringForKey ("helmip")); client.Port = NSUserDefaults.StandardUserDefaults.IntForKey("helmport"); client.PacketSize = 16384; client.SktEncoding = Encoding.Unicode; timer = new Timer(); timer.Interval = 5000f; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); #region Socket Events client.Connected += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Green; this.txtSktStatus.Text = "Connected"; }); }; client.Closed += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Red; txtSktStatus.Text = "Connection Closed!"; }); timer.Start(); }; client.MsgReceived += (x) => { ripper.EnqueueIfRegistered(x); }; client.SktError += new AsyncSkt.SktErrorEventHandler(client_SktError); client.GeneralEx += (x) => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Red; txtSktStatus.Text = "G.Ex: " + x.ToString(); }); timer.Start(); }; client.ConnectionAccepted += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Green; txtSktStatus.Text = "Connection Accepted!"; }); }; #endregion client.Connect(); }
public UpDown() : base("UpDown", null) { currentID = 12345; //ripper = new VonRipper(VonRipper.PacketType.XAnn | VonRipper.PacketType.XBkt | VonRipper.PacketType.XRun | VonRipper.PacketType.XHb); ripper = new VonRipper(VonRipper.PacketType.XRun | VonRipper.PacketType.XTrick | VonRipper.PacketType.XAnn); ripper.AnnouncementUpdate += new EventHandler(ripper_AnnouncementUpdate); ripper.RunUpdate += new EventHandler(ripper_RunUpdate); ripper.TrickUpdate += new EventHandler(ripper_trickUpdate); ripper.HeartbeatUpdate += (x, y) => { XHeartbeat hb = x as XHeartbeat; currentMCID = hb.MCID; currentCOMPID = hb.CompID; currentBracketID = hb.BracketID.ToString(); currentRoundID = hb.RoundID.ToString(); InvokeOnMainThread(delegate { timeStamp = hb.TOD; this.heartBeat.Text = currentMCID + "-" + timeStamp; }); }; client = new AsyncSkt(); client.EOL_Receive = ((char) 3).ToString(); client.EOL_Send = ((char) 3).ToString(); client.RemoteIP = IPAddress.Parse(NSUserDefaults.StandardUserDefaults.StringForKey ("helmip")); client.Port = NSUserDefaults.StandardUserDefaults.IntForKey("helmport"); client.PacketSize = 16384; client.SktEncoding = Encoding.Unicode; marshall = new AsyncSkt(); marshall.EOL_Receive = ((char) 3).ToString(); marshall.EOL_Send = ((char) 3).ToString(); marshall.RemoteIP = IPAddress.Parse(NSUserDefaults.StandardUserDefaults.StringForKey ("marshallip")); marshall.Port = NSUserDefaults.StandardUserDefaults.IntForKey("marshallport"); marshall.PacketSize = 16384; marshall.SktEncoding = Encoding.Unicode; marshall2 = new AsyncSkt(); marshall2.EOL_Receive = ((char) 3).ToString(); marshall2.EOL_Send = ((char) 3).ToString(); marshall2.RemoteIP = IPAddress.Parse(NSUserDefaults.StandardUserDefaults.StringForKey ("marshallip")); marshall2.Port =10191; marshall2.PacketSize=16384; marshall2.SktEncoding = Encoding.Unicode; timer = new Timer(); timer.Interval = 5000f; timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); #region Socket Events client.Connected += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Green; this.txtSktStatus.Text = "Connected"; }); }; client.Closed += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Red; txtSktStatus.Text = "Connection Closed!"; }); timer.Start(); }; client.MsgReceived += (x) => { ripper.EnqueueIfRegistered(x); }; marshall.MsgReceived +=(x) => { ripper.EnqueueIfRegistered(x); }; marshall2.MsgReceived +=(x) => { ripper.EnqueueIfRegistered(x); }; client.SktError += new AsyncSkt.SktErrorEventHandler(client_SktError); client.GeneralEx += (x) => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Red; txtSktStatus.Text = "G.Ex: " + x.ToString(); }); }; client.ConnectionAccepted += () => { InvokeOnMainThread(delegate { txtSktStatus.TextColor = UIColor.Green; txtSktStatus.Text = "Connection Accepted!"; }); }; #endregion client.Connect(); marshall.Connect(); marshall2.Connect(); }