public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting && PhotonNetwork.IsMasterClient) { if (streamDatas.Count != 0) { string _dataJson = JsonConvert.SerializeObject(streamDatas); byte[] _dataByte = ObjectSerialize.Serialize(_dataJson); stream.SendNext(_dataByte.Length); stream.SendNext(_dataByte); streamDatas.Clear(); byteStreamed = _dataByte.Length; } else { stream.SendNext(0); } } if (stream.IsReading) { int _byteCount = (int)stream.ReceiveNext(); if (_byteCount != 0) { byteStreamed = _byteCount; byte[] _dataBytes = (byte[])stream.ReceiveNext(); string _dataJson = (string)ObjectSerialize.DeSerialize(_dataBytes); Dictionary <StreamDataType, string> _datas = (Dictionary <StreamDataType, string>)JsonConvert.DeserializeObject(_dataJson, typeof(Dictionary <StreamDataType, string>)); foreach (KeyValuePair <StreamDataType, string> _data in _datas) { ClientManager.client.RecevingData(_data.Key, _data.Value); } } } }
public new bool Save(object param = null) { try { List <Type> knownTypes = new List <Type>() { }; // typeof(AnimationNodeViewModel), typeof(OutputNodeViewModel) }; string saveShadowCopy = this.Location + ".sbak"; ObjectSerialize.Serialize(this, saveShadowCopy as string, knownTypes); Folder = Path.GetDirectoryName(saveShadowCopy as string); Name = Path.GetFileNameWithoutExtension(saveShadowCopy as string); File.Copy(saveShadowCopy, saveShadowCopy.Replace(".sbak", ""), true); } catch (Exception ex) { MessageBox.Show(ex.Message); } return(true); }
private void Button_Click(object sender, RoutedEventArgs e) { try { // ObservableCollection<ConnectionViewModel> test = new ObservableCollection<ConnectionViewModel>(); AnimationNodeViewModel evm = new AnimationNodeViewModel(); OutputNodeViewModel onvm = new OutputNodeViewModel(); OutputConnectorViewModel opcvm = new OutputConnectorViewModel() { Element = evm }; InputConnectorViewModel ipcvm = new InputConnectorViewModel() { Element = onvm }; var cvm = new ConnectionViewModel() { From = opcvm, To = ipcvm }; //test.Add(); List <Type> knownTypes = new List <Type>() { typeof(AnimationNodeViewModel), typeof(OutputNodeViewModel) }; AnimationComponent ac = new AnimationComponent(); ac.FB_AnimationComponent.AnimationBlendTree.AnimNodes.Add(evm); ac.FB_AnimationComponent.AnimationBlendTree.AnimNodes.Add(onvm); ac.FB_AnimationComponent.AnimationBlendTree.NodeConnections.Add(cvm); ObjectSerialize.Serialize(ac, "./test", knownTypes); // var testRes = ObjectSerialize.Deserialize<AnimationComponent>("./test"); var testRes = ObjectSerialize.Deserialize <VEXProjectModel>(@"F:\Projekte\coop\XGame\data\Editor\New VEX Project xyy.oideProj"); } catch (Exception ex) { } }
public bool Send(string queueName, string routingKey, MessageDto message) { try { lock (_factory) { using (_connection = _factory.CreateConnection()) { using (_model = _connection.CreateModel()) { _model.ExchangeDeclare(_rabbitMQSettings.ExchangeName, _rabbitMQSettings.Type, durable: true); _model.QueueDeclare(queueName, true, false, false, null); _model.QueueBind(queueName, _rabbitMQSettings.ExchangeName, routingKey); message.InstanceId = Me.GetInstance().Id; message.RequestId = Guid.NewGuid(); message.CreateAt = DomainUtils.GetLocalDate(); byte[] objsend = ObjectSerialize.Serialize(message); _model.BasicPublish(_rabbitMQSettings.ExchangeName, routingKey, null, objsend); } } } using (var scope = Services.CreateScope()) { var scopedProcessingService = scope.ServiceProvider.GetRequiredService <IMessageService>(); scopedProcessingService.InsertAsync(message).Wait(); } return(true); } catch (System.Exception ex) { System.Console.WriteLine(ex.ToString()); _model.Dispose(); _connection.Dispose(); return(false); } }
public void OnPhotonSerializeView(PhotonStream _stream, PhotonMessageInfo info) { if (_stream.IsWriting) { List <string> _jsonData = new List <string> { JsonConvert.SerializeObject(plyCl.mysteryPower), JsonConvert.SerializeObject(plyCl.BombeCount), JsonConvert.SerializeObject(plyCl.powerUps) }; string _json = JsonConvert.SerializeObject(_jsonData); _stream.SendNext(ObjectSerialize.Serialize(_json)); } else { List <string> _jsonData = JsonConvert.DeserializeObject <List <string> >((string)ObjectSerialize.DeSerialize((byte[])_stream.ReceiveNext())); plyCl.mysteryPower = JsonConvert.DeserializeObject <MysteryPower.MysteryPowers>(_jsonData[0]); plyCl.BombeCount = JsonConvert.DeserializeObject <int>(_jsonData[1]); plyCl.powerUps = JsonConvert.DeserializeObject <Dictionary <PowerUps, int> >(_jsonData[2]); } }
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting && PhotonNetwork.IsMasterClient) { if (Maps == null) { return; } stream.SendNext(map.GetLength(0)); stream.SendNext(map.GetLength(1)); UpdateMap(boxSync); List <string> boxSyncJson = new List <string>(); foreach (Box _box in boxSync) { boxSyncJson.Add(JsonConvert.SerializeObject(_box)); } stream.SendNext(ObjectSerialize.Serialize(JsonConvert.SerializeObject(boxSyncJson))); boxSync = new List <Box>(); } if (stream.IsReading) { int x = (int)stream.ReceiveNext(); int y = (int)stream.ReceiveNext(); if (map == null) { map = new Box[x, y]; } byte[] receving = (byte[])stream.ReceiveNext(); List <string> boxSyncJson = JsonConvert.DeserializeObject <List <string> >((string)ObjectSerialize.DeSerialize(receving)); List <Box> _boxSync = new List <Box>(); foreach (string boxJson in boxSyncJson) { Box _box = JsonConvert.DeserializeObject <Box>(boxJson); _boxSync.Add(_box); map[_box.pos.x, _box.pos.y] = _box; } UpdateMap(_boxSync); } }