You must Sign In to post a response.
  • Category: ASP.Net MVC

    How to create a script widget for live support chat

    i am working on a live chat support project using mvc and LSCK signalR for chatting between Agent and user i want to create a script to call chat application from any website just paste script in head section chat box will be display on bottom right of web page

    I want to create script like this :

    <!--Start of Zopim Live Chat Script-->
    <script type="text/javascript">
    window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
    d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
    _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
    $.src="//v2.zopim.com/?3f259wGMlHGR6WOJzO9WgBIMaPsh01iq";z.t=+new Date;$.
    type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
    </script>
    <!--End of Zopim Live Chat Script-->


    please give me suggestion for that how can i create script like this in mvc
  • #764513
    You can past the script in the header section of html tag.

    If you are using master layout. You can create rendersection in the master layout

    @RenderSection("scripts", required: false)


    try @section scripts in your views

    @section scripts
    {
    <!--Start of Zopim Live Chat Script-->
    <script type="text/javascript">
    window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
    d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
    _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute("charset","utf-8");
    $.src="//v2.zopim.com/?3f259wGMlHGR6WOJzO9WgBIMaPsh01iq";z.t=+new Date;$.
    type="text/javascript";e.parentNode.insertBefore($,e)})(document,"script");
    </script>
    <!--End of Zopim Live Chat Script-->

    }

    By Nathan
    Direction is important than speed

  • #764516
    I think with the help of 'SignalR Hub Class item' you can build chat room, first you need to use below classes
    Microsoft.ASp.NET.SingnalR.Core
    Microsoft.ASp.NET.SingnalR.owin
    Microsoft.ASp.NET.SingnalR.systemweb
    you will get good sample on below link
    http://www.codeproject.com/Articles/562023/Asp-Net-SignalR-Chat-Room

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764542
    SignalR is one of the prominent features to build application to connect social application, multiuser games, news weather etc. Here is a piece of code snippet to connect with chat room

    public void Connect(string userName)
    {

    var id = Context.ConnectionId;

    if (ConnectedUsers.Count(x => x.ConnectionId == id) == 0)
    {

    ConnectedUsers.Add(new UserDetail { ConnectionId = id, UserName = userName });

    Clients.Caller.onConnected(id, userName, ConnectedUsers, CurrentMessage);

    Clients.AllExcept(id).onNewUserConnected(id, userName);

    }

    }


Sign In to post your comments