private ConcurrentQueue <Cell> CellsQueue; // kolejka Cell /* Tworzy węzeł kliencki o danejkonfiguracji */ public Client(Configuration.NetworkElement networkElement) { this.AAL = new AAL(); this.id = networkElement.Info.ID; this.name = networkElement.Info.Name; this.Log = new Log(); this.messages = new ConcurrentQueue <string>(); Log.Queue.Enqueue(this.id.ToString()); CellsQueue = new ConcurrentQueue <Cell>(); List <Configuration.PortInput> inputPorts = networkElement.PortsIn; List <int> inputPortsIds = new List <int>(); foreach (Configuration.PortInput port in inputPorts) { inputPortsIds.Add(port.Id); } portsIn = new PortsIn(Receive, this.Log, id, inputPortsIds); List <Configuration.PortOutput> outputPorts = networkElement.PortsOut; List <int> outputPortsIds = new List <int>(); foreach (Configuration.PortOutput port in outputPorts) { outputPortsIds.Add(port.Id); } portsOut = new PortsOut(this.Log, id, outputPortsIds); }
private void receiver() { if (networkStream == null) { networkStream = new NetworkStream(cloudSocket); //tworzy string 'Node ' i tu jego numer String welcomeString = "Node " + ((myAddress.subnet * 100) + myAddress.host) + " " + myAddress.ToString(); //tworzy tablicę bajtów z tego stringa byte[] welcomeStringBytes = AAL.GetBytesFromString(welcomeString); //wysyła tą tablicę bajtów streamem networkStream.Write(welcomeStringBytes, 0, welcomeStringBytes.Length); } BinaryFormatter bf = new BinaryFormatter(); try { receivedPacket = (Packet.ATMPacket)bf.Deserialize(networkStream); if (receivedPacket.VPI == -1 && receivedPacket.VCI == -1) { LRM.OdczytajATM(receivedPacket); } else { queuedReceivedPackets.Enqueue(receivedPacket); } //to może nie działać. Sprawdzi się jeszcze /*if (!sendThread.IsAlive) { * sendThread = new Thread(this.sender); * sendThread.IsBackground = true; * sendThread.Start(); * }*/ receiver(); } catch (Exception e) { if (isDisconnect) { SetText("Rozłączam się z chmurą!\n"); isDisconnect = false; networkStream = null; } else { SetText("Coś poszło nie tak : " + e.Message + "\n"); } } }
public String FromPayload(byte[] payload) { return(AAL.GetStringFromBytes(payload)); }
public byte[] ToPayload(String str) { return(AAL.GetBytesFromString(str)); }
public void DoOneFrame() { if (!Active) { return; } Count += Time.deltaTime * Speed[PreviousStep]; if (Count >= 1) { Count = 1; Animate(); Count = 0; if (NextStep == 0 && LoopTo == -1) { Active = false; //Count = 0; return; } PreviousStep = NextStep; if (NextStep < GoalStep) { NextStep++; } else if (NextStep > GoalStep) { if (OneWay) { FinishedHalf = true; Active = false; } NextStep--; if (ImmidiateReturn) { if (LoopTo != -1) { NextStep = LoopTo; } else { NextStep = 0; } } } if (NextStep == LoopTo && LoopTo != -1) { GoalStep = PreviousGoal; } if (NextStep == GoalStep) { PreviousGoal = GoalStep; GoalStep = LoopTo; } if (Active) { for (int i = 0; i < Parts.Count; i++) { try { bool BaseValue = AnimationParts[PreviousStep][Pointers[PreviousStep][i]].gameObject.activeSelf; bool FinalValue = AnimationParts[NextStep][Pointers[NextStep][i]].gameObject.activeSelf; if (BaseValue != FinalValue || AffectAll) { Parts[i].gameObject.SetActive(FinalValue); } } catch { } } } AdvancedAnimationListeners.ForEach(AAL => AAL.OnStepChange(NextStep)); } Animate(); }