Beispiel #1
0
 public void Send(string sData)
 {
     if (sData == null)
     {
         return;
     }
     DBSend.Set(sData);
 }
Beispiel #2
0
 public void Send(byte[] data)
 {
     if (data == null)
     {
         return;
     }
     DBSend.Write(data);
 }
Beispiel #3
0
        private bool Send()
        {
            byte[] data;

            if (SLClient == null ||
                DBSend == null ||
                !SLClient.Connected ||
                DBSend.IsAllRead ||
                !DBSend.Read(out data))
            {
                return(false);
            }


            byte[] result_data = TcpAsyncCommon.CreatePacket(data, PacketMode);// result.ToArray();

            if (result_data.IsNullOrEmpty())
            {
                return(false);
            }

            int sent = 0;
            int size = result_data.Length;

            SendTimeout.Reset();
            do
            {
                int packet = size - sent;
                if (packet > TcpAsyncServer.PacketSizeTCP)
                {
                    packet = TcpAsyncServer.PacketSizeTCP;
                }
                try
                {
                    sent += SLClient.Send(result_data, sent, packet, SocketFlags.None);
                    //Thread.Sleep(1);
                }
                catch (Exception ex)
                {
                    Exceptions.Write(ex);
                    this.StopClient();
                    return(false);
                }

                if (SendTimeout.IsTriggered)
                {
                    return(false);
                }
            }while (sent < size);

            return(true);
        }
    void Update()
    {
        timeDelta += Time.deltaTime;

        // check periodically
        if (timeDelta > checkFreq)
        {
            timeDelta = 0.0f;

            targetSet = GameObject.FindGameObjectsWithTag(countTag); // update set of objects
            if (targetSet.Length == countAmount)
            {
                DBSend.Score(GameState.Singleton.score);
                DBSend.ActionTrace(GameState.Singleton.actionTrace);
                Application.LoadLevel(Application.loadedLevel); // restart level
            }
        }
    }
Beispiel #5
0
        private bool Send()
        {
            if (!SLClient.Connected || !DBSend.IsDataAvalaible)
            {
                return(false);
            }

            string sData = DBSend.Get(false); //Don't increment data, becouse it is not certain at this point, if it will be send

            if (sData == null)
            {
                return(false);
            }

            sData.Replace(@"\", @"\\");
            sData = sData + TcpAsyncCommon.EOM;

            byte[] baData = Encoding.ASCII.GetBytes(sData);

            if (baData.Length > 1024)
            {
                throw new Exception("Exception in Send() method, packet size is to large.");
            }

            try
            {
                SLClient.Send(baData);
            }
            catch
            {
                return(false);
            }

            DBSend.IndexerIcrement(); //Increment indexer, becouse data was successfully send.
            return(true);
        }