void UpdateMessage(Message message, Conversation conversation) { message.ConversationIdentifier = conversation.ConversationIdentifier; ClientState.Current.DataService.Update(message); Thread.CurrentThread.ExecuteOnUIThread(() => conversation.Add(message)); }
public async void WindowLoaded() { Action <Model.Message> onMessageReceivedCallback = (Model.Message x) => { if (x.Content != "") { Application.Current.Dispatcher.Invoke((Action) delegate { // Push the current message to the window var newMessageView = new View.UIComponent.Message(); var context = newMessageView.DataContext as MessageViewModel; context.Content = x.Content; context.Time = x.Time; if (x.SenderID == SenderID) // Current user owns the message { context.SenderName = SenderName; newMessageView.HorizontalAlignment = HorizontalAlignment.Right; } else { context.SenderName = ReceiverName; newMessageView.HorizontalAlignment = HorizontalAlignment.Left; } Conversation.Add(newMessageView); }); } }; await Model.ChatModel.Instance.SendMessage("", SenderID, ReceiverID, DateTime.Now); Model.ChatModel.Instance.ObserveConversation(SenderID, ReceiverID, onMessageReceivedCallback); }
private void SendMessage() { var message = new Message(DateTime.UtcNow, User, Typing); channel.Send(message); Typing = string.Empty; Conversation.Add(new MessageViewModel(message, true)); }
public void Send() { var message = new Message { From = Initiator.Name, Initiator = Initiator, To = Contact.Name, Contact = Contact, Value = Message, IsMine = true, DateReceived = DateTime.Now }; SendMessage(this, new ChatSessionEventArgs(Contact, message)); Conversation.Add(message); Message = String.Empty; }
private void Start_Click(object sender, RoutedEventArgs e) { requester = new ConversationRequester(); Character bela = new Character("Bela"); Conversation c = new Conversation(); c.Add(new ConversationTextNode().WithSubject(bela).WithText("Ez egy ilyen nap..."), new ConversationTextNode().WithText("örökké nem süthet").WithSubject(bela), new ConversationTextNode().WithSubject(bela).WithText("éjjel sincs fent a nap") ); c.Add( new ConversationChoiceNode().WithQuestion("REALLY?").AddChoice("Something Different", new Conversation().WithAdd(new ConversationTextNode().WithSubject(bela).WithText("Something right, something wrong"), new ConversationTextNode().WithSubject(bela).WithText("Something missing, something different")) ) .AddChoice("Whatever it takes", new Conversation().WithAdd(new ConversationTextNode().WithSubject(bela).WithText("I do whatever it takes"), new ConversationTextNode().WithSubject(bela).WithText("To make your doom") ))); Statement st = Statement.CreateStatement(125, 130); Statement st2 = Statement.CreateStatement(false, false); c.Add(new ConversationStatementNode().WithIf(new LinkedStatement(new Conversation().WithAdd(new ConversationTextNode().WithText("IF ÁG").WithSubject(bela))) .Initialize(st, st.GreaterOrEquals) ).WithElse(new LinkedStatement(new Conversation().WithAdd(new ConversationTextNode().WithSubject(bela).WithText("else ág"))).Initialize(st2, st2.Equals))); requester.Engine = new TestCase(); requester.Engine.CurrentConversation = c; }
public static void Pack(Conversation conversation, Frame frame, MessageType type, String content) { if (null == conversation) { throw new ArgumentNullException("conversation"); } if (null == frame) { throw new ArgumentNullException("frame"); } content = TSharkHelper.GetFrameWithoutHeader(content); String[] lines = content.SplitToLines(); String cSeqStr = lines.FirstOrDefault(item => item.Contains("CSeq")); if (null == cSeqStr) { return; } cSeqStr = cSeqStr.Substring(cSeqStr.IndexOf(":", StringComparison.Ordinal) + 1).Trim(); int cSeq = int.Parse(cSeqStr); switch (type) { case MessageType.Request: RtspMethod method = GetMethod(lines.First(item => item.Contains("Method"))); conversation.Add(new RequestResponsePair(new RtspRequest(frame, conversation, cSeq, method), null, frame.FoundInTrace, conversation, ContentType.Rtsp)); break; case MessageType.Response: var pair = conversation.GetMessages(ContentType.Rtsp).FirstOrDefault(item => item.GetRequest <RtspRequest>().CSeq == cSeq && item.Response.IsEmpty); if (null != pair) { pair.SetResponse(new RtspResponse(frame, conversation, cSeq)); } break; } String filename = FrameHelper.GetFrameFilename(conversation, frame, type); File.WriteAllText(filename, content); }
public void CreateDialogueFromEditor() { if (editorConvos != null) { convos = new List <Conversation>(); //for every conversation for (int i = 0; i < editorConvos.Length; i++) { Conversation temp = new Conversation(); //for every line in that conversation for (int j = 0; j < editorConvos[i].lines.Length; j++) { temp.Add(MakeLine(editorConvos[i].lines[j])); } convos.Add(temp); } } }
public void GetAllDbMessages(Conversation c) { SQLiteCommand command = new SQLiteCommand( "select number,message,timestamp from messages group by number", dbConn); command.ExecuteNonQuery(); SQLiteDataReader read = command.ExecuteReader(); if (read.HasRows) { while (read.Read()) { string number = read.GetString(0); string message = read.GetString(1); string timestamp = read.GetString(2); c.Add(number, message, timestamp); } } }
// Use this for initialization void Start() { Screen.sleepTimeout = SleepTimeout.NeverSleep; MainCamera = GameObject.FindObjectOfType <Camera>(); ConversationBehaviour = GameObject.FindObjectOfType <ConversationBehaviour>(); IntroConv = new Conversation(); IntroConv.Add(new DelegateLine(delegate() { StartCoroutine(MoveCamera(new Vector3(0, 2f, MainCamera.transform.position.z), 0.2f)); })); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "London, 1903", 2f)); //IntroConv.Add(new DialogueLine(SpeakerType.Sound, "Doctor Allophone's Workshop", 2f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 3f)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 1f; })); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.1f)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 0f; })); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "*bang*", 1)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.5f)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 1f; })); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.1f)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 0f; })); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "*crash*", 1)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 1f)); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "I've done it!", 1.5f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.5f)); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "At last, my flying machine is complete!", 2f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.5f)); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "Go and pull that lever!", 2f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.25f)); IntroConv.Add(new DialogueLine(SpeakerType.Player, "Are you sure this will work?", 2f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.25f)); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "It's my greatest invention! Of course it will work!", 2f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.3f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "*clunk*", 1)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.5f)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 0.1f; })); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "*whir*", 1)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.5f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "*rattle*", 1)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 0.2f; })); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "Look out!", 0.5f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "*crash*", 1)); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "Oh no! It's going to...", 0.05f)); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "Not that stack of papers!", 0.2f)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 0.5f; })); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "*smash*", 1)); IntroConv.Add(new DelegateLine(delegate() { CameraShake = 0; })); IntroConv.Add(new DelegateLine(delegate() { StartCoroutine(MoveCamera(new Vector3(0, 3.5f, MainCamera.transform.position.z), 1f)); })); IntroConv.Add(new DelegateLine(delegate() { StartCoroutine(FountainAnimation()); })); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "My inventions!", 2f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.25f)); IntroConv.Add(new DialogueLine(SpeakerType.Professor, "Quick! Into the flying machine!\nGet my designs back before they blow away!", 3f)); IntroConv.Add(new DialogueLine(SpeakerType.Sound, "", 0.5f)); IntroConv.Add(new DelegateLine(delegate() { Application.LoadLevel("main"); })); ConversationBehaviour.StartConversation(IntroConv); }
private void ChannelReceived(object sender, Message e) { Conversation.Add(new MessageViewModel(e, false)); }
public JsonResult ReplyBottle(Conversation conversation) { lock (lockReply) { //验证密匙 if (Common.SecureHelper.MD5(conversation.BottleID + Common.SecureHelper.JeasuAutoKey) == conversation.MassageKey) { //Bottle bottle = new Bottle(); if (string.IsNullOrWhiteSpace(conversation.Massage)) { return(Json(new Result(false, "多少说点东西!"), JsonRequestBehavior.AllowGet)); } //Bottle bottle = new Bottle(); if (conversation.Massage.Length <= 3) { return(Json(new Result(false, "内容太少咯,请多说点!"), JsonRequestBehavior.AllowGet)); } if (conversation.Massage.Length > 300) { return(Json(new Result(false, "内容太多了!"), JsonRequestBehavior.AllowGet)); } //如果FirstReplyUserID不为null 则说明有人回复过了 if (ServiceHelper.GetBottleService.Exists(t => t.ID == conversation.BottleID && t.FirstReplyUserID != null && t.CreateUserID != CurrentInfo.CurrentUser.ID && t.FirstReplyUserID != CurrentInfo.CurrentUser.ID)) { return(Json(new Result(false, "来迟了,瓶子已经被回复,请换个瓶子试试"), JsonRequestBehavior.AllowGet)); } Bottle bottle = ServiceHelper.GetBottleService.GetEntity((int)conversation.BottleID, false); //如果是第一个回复,则也需要把瓶子插入到回话中 if (!ServiceHelper.GetConversationService.Exists(t => t.BottleID == conversation.BottleID)) { //第一个回复的人不可以是自己 if (bottle.CreateUserID == CurrentInfo.CurrentUser.ID) { return(Json(new Result(false, "还是等有缘人回复把"), JsonRequestBehavior.AllowGet)); } Conversation cv = new Conversation(); cv.Massage = bottle.Massage; cv.BottleID = conversation.BottleID; cv.CreateUserName = bottle.CreateUserName; cv.CreateUserID = bottle.CreateUserID; cv.CreateTime = bottle.CreateTime; cv.Sexual = bottle.Sexual; cv.Add(); //更新瓶子的回复人 bottle.FishingCount = bottle.FishingCount + 1;//被打捞了一次 bottle.FirstReplyUserID = CurrentInfo.CurrentUser.ID; //如果是管理员,则随机名字 if (CurrentInfo.CurrentUser.ID == 6) { string netUser = "******"; Random rd = new Random(); if (bottle.Sexual == true) { netUser = NetUserNames.NetUserGirl[rd.Next(0, NetUserNames.NetUserGirl.Count)]; } else { netUser = NetUserNames.NetUserBoy[rd.Next(0, NetUserNames.NetUserBoy.Count)]; } bottle.FirstReplyUserName = netUser; } else { bottle.FirstReplyUserName = CurrentInfo.CurrentUser.RealName; } //扣除金币 CurrentInfo.CurrentUser.GoldCoin = CurrentInfo.CurrentUser.GoldCoin == null ? 0 : CurrentInfo.CurrentUser.GoldCoin; CurrentInfo.CurrentUser.Fishing = CurrentInfo.CurrentUser.Fishing - 1; } //bottle.Update(); conversation.CreateUserID = CurrentInfo.CurrentUser.ID; //如果是管理员,则随机名字,取上创建人的名字 if (CurrentInfo.CurrentUser.ID == 6) { //说明这个瓶子是管理员自己发的 if (bottle.CreateUserID == 6) { conversation.CreateUserName = bottle.CreateUserName; conversation.Sexual = bottle.Sexual; } else//如果这个瓶子是别人发的 { conversation.CreateUserName = bottle.FirstReplyUserName; conversation.Sexual = !((bool)bottle.Sexual); } } else { conversation.CreateUserName = CurrentInfo.CurrentUser.RealName; conversation.Sexual = CurrentInfo.CurrentUser.Sexual; } conversation.CreateTime = DateTime.Now; conversation.MassageKey = string.Empty; //设置瓶子的最后回复内容 bottle.LastReplyUserID = CurrentInfo.CurrentUser.ID; if (CurrentInfo.CurrentUser.ID == 6)//如果是管理员则设置最后回复名字是自动生成的 { bottle.LastReplyUserName = conversation.CreateUserName; } else { bottle.LastReplyUserName = CurrentInfo.CurrentUser.RealName; } bottle.LastReplyMassage = conversation.Massage; bottle.LastReplyTime = DateTime.Now; bottle.Update(); bool flage = conversation.Add() == null ? false : true; return(Json(new Result(flage, ResultType.Other), JsonRequestBehavior.AllowGet)); } else { return(Json(new Result(false, "发生错误,回复失败"), JsonRequestBehavior.AllowGet)); } } }
public void MessageReceived(Message message) { message.DateReceived = DateTime.Now; Conversation.Add(message); }
public void AddMessage(Message message) { Conversation.Add(message); }
void Start() { Screen.sleepTimeout = SleepTimeout.NeverSleep; PlayerBehaviour = GameObject.FindObjectOfType <PlayerBehaviour>(); ConversationBehaviour = GameObject.FindObjectOfType <ConversationBehaviour>(); ScoreText = GameObject.Find("ScoreText").GetComponent <Text>(); Score = 0; microphoneController = GetComponent <MicTools.MicrophoneController>(); microphoneInput = GetComponent <MicTools.MicrophoneInput>(); microphoneController.microphoneActive = true; Conversation startConvo = new Conversation(); startConvo.Add(new GamePauseLine(true)); startConvo.Add(new DelegateLine(delegate() { PlayerBehaviour.GravityEnabled = false; PlayerBehaviour.SpeechEnabled = false; StartCoroutine(IntroAnimation()); })); startConvo.Add(new DialogueLine(SpeakerType.Professor, "It works!", 2)); startConvo.Add(new DialogueLine(SpeakerType.Sound, "", 2)); startConvo.Add(new GamePauseLine(false)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "Right. See that thing you're holding? Turn that to move left and right.", 4)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "Or you can use my new invention, the QWERTY keyboard.", 2)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "Use the left and right arrow keys.", 3)); startConvo.Add(new DelegateLine(delegate() { PlayerBehaviour.GravityEnabled = true; })); startConvo.Add(new DialogueLine(SpeakerType.Professor, "Look out! You're falling", 0.2f)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "The flying machine is powered by words. Say something quick!", 0.1f)); startConvo.Add(new DelegateLine(delegate() { PlayerBehaviour.SpeechEnabled = true; })); startConvo.Add(new DialogueLine(SpeakerType.Sound, "Doc: The flying machine is powered by words. Say something quick!", 2f)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "My patented phono-motor converts speech into motion.", 2f)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "The more ridiculous a phrase, the more thrust the phono-motor can generate.", 2f)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "Don't worry! I compiled a dictionary of ridiculous phrases for just such an occasion!", 2f)); startConvo.Add(new DialogueLine(SpeakerType.Professor, "Now where did I put it?...", 1.5f)); startConvo.Add(new DelegateLine(delegate() { CreateBlueprints(); })); startConvo.Add(new DialogueLine(SpeakerType.Sound, " ", 1f)); startConvo.Add(new DelegateLine(delegate() { ConversationBehaviour.StartConversation(new RandomSuggestionConversation()); })); ConversationBehaviour.StartConversation(startConvo); }