示例#1
0
        static void Main(string[] args)
        {
            SendBirdClient.Init("52C4347B-C9B0-4E62-81D6-96EB40517902");

            //SendBirdClient.Connect("tom", (User user, SendBirdException e) =>
            //{
            //    if (e != null)
            //    {
            //        // Error
            //        return;
            //    }
            //});

            OpenChannel.GetChannel("sendbird_open_channel_43739_172b1997dcc4c9bbfc49bc0533303c8017bb2d70", (OpenChannel openChannel, SendBirdException e) => {
                if (e != null)
                {
                    // Error!
                    return;
                }

                Console.WriteLine("canale aperto");
                // Successfully fetched the channel.
                // Do something with openChannel.
            });

            Console.Read();
        }
示例#2
0
    void LoadOpenChannels()
    {
        mChannelListQuery.Next((list, e) => {
            if (e != null)
            {
                Debug.Log(e.Code + ": " + e.Message);
                return;
            }

            foreach (OpenChannel channel in list)
            {
                GameObject btnChannel = Instantiate(channelListItemPrefab) as GameObject;
                btnChannel.GetComponent <Image>().sprite = uiTheme.channelButtonOff;

                if (channel.Url == selectedChannelUrl)
                {
                    btnChannel.GetComponent <Image>().overrideSprite = uiTheme.channelButtonOn;
                    btnChannel.GetComponentInChildren <Text>().color = uiTheme.channelButtonOnColor;
                }
                else
                {
                    btnChannel.GetComponent <Image>().overrideSprite = null;
                    btnChannel.GetComponentInChildren <Text>().color = uiTheme.channelButtonOffColor;
                }
                Text text = btnChannel.GetComponentInChildren <Text>();
                text.text = "#" + channel.Name;
                btnChannel.transform.SetParent(channelGridPannel.transform);
                btnChannel.transform.localScale = Vector3.one;
                btnChannels.Add(btnChannel);

                OpenChannel final = channel;
                btnChannel.GetComponent <Button>().onClick.AddListener(() => {
                    foreach (KeyValuePair <string, OpenChannel> entry in enteredChannels)
                    {
                        entry.Value.Exit(null);
                    }

                    final.Enter((e1) => {
                        if (e1 != null)
                        {
                            Debug.Log(e1.Code + ": " + e1.Message);
                            return;
                        }

                        currentChannel = final;
                        LoadOpenChannelChatHistory();
                        txtOpenChannelTitle.text = "#" + final.Name;

                        enteredChannels[final.Url] = final;

                        openChannelListPanel.SetActive(false);
                        openChannelPanel.SetActive(true);
                    });
                });
            }
        });
    }
示例#3
0
    public void CreateChannel(string name, Action <OpenChannel, Exception> onChannelCreated)
    {
        var code = Math.Abs(name.GetHashCode()).ToString().Substring(0, 6);

        OpenChannel.CreateChannel(name, null, code.ToString(), (channel, e) =>
        {
            if (e != null)
            {
                Debug.LogError(e);
            }
            onChannelCreated?.Invoke(channel, e);
        });
    }
        private async Task FetchChannelMessages(OpenChannel channel)
        {
            var tcs = new TaskCompletionSource <SendBirdException>();

            var prevMessageListQuery = channel.CreatePreviousMessageListQuery();

            prevMessageListQuery.Load(30, false, (messages, ex) =>
            {
                HandleMessages(messages);
                tcs.SetResult(ex);
            });

            HandleException(await tcs.Task);
        }
        private async Task LeaveChannel()
        {
            if (_channel == null)
            {
                return;
            }

            var tcs = new TaskCompletionSource <SendBirdException>();

            _channel.Exit(tcs.SetResult);
            await tcs.Task;

            _channel = null;
        }
        private async Task <OpenChannel> CreateChannel(string channelName)
        {
            var         tcs     = new TaskCompletionSource <SendBirdException>();
            OpenChannel channel = null;

            OpenChannel.CreateChannel(channelName, null, null, (openChannel, ex) => {
                Console.WriteLine($"SendBird: Created channel \"{openChannel.Name}\"");
                channel = openChannel;
                tcs.SetResult(ex);
            });

            HandleException(await tcs.Task);
            return(channel);
        }
示例#7
0
    void OpenOpenChannelList()
    {
        openChannelListPanel.SetActive(true);

        foreach (UnityEngine.Object btnChannel in btnChannels)
        {
            GameObject.Destroy(btnChannel);
        }
        btnChannels.Clear();


        mChannelListQuery       = OpenChannel.CreateOpenChannelListQuery();
        mChannelListQuery.Limit = 50;
        LoadOpenChannels();
    }
        private async Task EnterChannel(OpenChannel channel)
        {
            var tcs = new TaskCompletionSource <SendBirdException>();

            await LeaveChannel();

            channel.Enter(ex => {
                Console.WriteLine($"SendBird: Entered channel \"{channel.Name}\"");
                tcs.SetResult(ex);
            });

            HandleException(await tcs.Task);

            _channel = channel;
        }
示例#9
0
    void OpenLiveUserList()
    {
        foreach (UnityEngine.Object btnUser in btnUsers)
        {
            GameObject.Destroy(btnUser);
        }
        btnUsers.Clear();

        userListPanel.SetActive(true);
        OpenChannel openChannel = (OpenChannel)currentChannel;

        mUserListQuery       = openChannel.CreateParticipantListQuery();
        mUserListQuery.Limit = 50;

        LoadUsers();
    }
示例#10
0
    private void GetChannelFromList(string channelMetadata, Action <OpenChannel, SendBirdException> resultHandler)
    {
        OpenChannelListQuery query = OpenChannel.CreateOpenChannelListQuery();

        query.Next((channels, e) =>
        {
            if (e != null)
            {
                Debug.LogError(e);
                resultHandler?.Invoke(null, e);
                return;
            }
            var channel = channels.Find(c => c.Data == channelMetadata);
            resultHandler?.Invoke(channel, e);
        });
    }
示例#11
0
    public void GetListOpenGroup()
    {
        string s = "";
        OpenChannelListQuery mChannelListQuery = OpenChannel.CreateOpenChannelListQuery();

        mChannelListQuery.Next((List <OpenChannel> channels, SendBirdException e) =>
        {
            if (e != null)
            {
                // Error.
                return;
            }
            Debug.Log(channels[0].Url);
            EnterChannel(channels[0].Url);
        });
    }
        private async Task <List <OpenChannel> > GetChannels(string channelName = null)
        {
            var tcs = new TaskCompletionSource <SendBirdException>();

            var result           = new List <OpenChannel>();
            var channelListQuery = OpenChannel.CreateOpenChannelListQuery();

            channelListQuery.NameKeyword = channelName;
            channelListQuery.Next((channels, ex) =>
            {
                result = channels;
                tcs.SetResult(ex);
            });

            HandleException(await tcs.Task);
            return(result);
        }
示例#13
0
        public void joinChannelHandler(object sender, EventArgs e)
        {
            OpenChannel.GetChannel("testing", (channel, sendExcep) =>
            {
                if (sendExcep != null)
                {
                    // An error has occurred while connecting.
                    System.Diagnostics.Debug.WriteLine("An error has occurred " +
                                                       "in joinChannelHandler while joining");
                    System.Diagnostics.Debug.WriteLine("error: " + sendExcep.Code);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Success in joining a channel in SendBird!");
                }

                channel.Enter((SendBirdException enterExcep) =>
                {
                    if (enterExcep != null)
                    {
                        System.Diagnostics.Debug.WriteLine("An error has occurred " +
                                                           "in joinChannelHandler while entering");
                        System.Diagnostics.Debug.WriteLine("error: " + sendExcep.Code);
                    }
                });

                channel.SendUserMessage("Test", (message, sendUserTestE) =>
                {
                    if (sendUserTestE != null)
                    {
                        System.Diagnostics.Debug.WriteLine("Error occurred when sending user message" +
                                                           " from inside joinChannelHandler");
                        System.Diagnostics.Debug.WriteLine("error: " + sendUserTestE.Code);
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Successfully sent message");
                    }
                });
            });
        }
示例#14
0
 public void EnterChannel(string name, Action <OpenChannel, Exception> onChannelEntered)
 {
     GetChannelFromList(name, (channel, e) =>
     {
         if (e != null)
         {
             Debug.LogError(e);
             onChannelEntered?.Invoke(null, e);
             return;
         }
         channel.Enter(e2 =>
         {
             if (e2 != null)
             {
                 Debug.LogError(e2);
             }
             this.channel = channel;
             RoomCode     = channel.Data;
             onChannelEntered?.Invoke(channel, e2);
         });
     });
 }
示例#15
0
    public void EnterChannel(string CHANNEL_URL)
    {
        OpenChannel.GetChannel(CHANNEL_URL, (OpenChannel openChannel, SendBirdException e) =>
        {
            if (e != null)
            {
                // Error.
                return;
            }
            _openChannel = openChannel;
            _openChannel.Enter((SendBirdException e3) =>
            {
                if (e3 != null)
                {
                    // Error.
                    return;
                }

                GetPreviousOpenChannelData();
            });
        });
    }
示例#16
0
文件: GeoTag.cs 项目: wencesui/GeoTag
        private bool ApplyTagFromUI2Selection(string strFunctionCode)
        {
            bool retVal = false;

            try
            {
                GeoTagDataBase oGeoTagDataBase = null;

                string strClassName = Commons.MapFunctionCode2ClassName(strFunctionCode);

                if (strFunctionCode == "PND")
                {
                    oGeoTagDataBase = new Pond();
                }
                else if (strFunctionCode == "ROAD")
                {
                    oGeoTagDataBase = new Road();
                }
                else if (strFunctionCode == "CHN")
                {
                    oGeoTagDataBase = new OpenChannel();
                }
                else if (strFunctionCode == "EMB")
                {
                    oGeoTagDataBase = new Embankment();
                }
                else if (strFunctionCode == "DIKE")
                {
                    oGeoTagDataBase = new Dike();
                }
                else if (strFunctionCode == "RW")
                {
                    oGeoTagDataBase = new RetainWall();
                }

                oGeoTagDataBase.Tag_Number = this.lblTagValue.Text;

                oGeoTagDataBase.Tag_Status          = this.cmbTagStatus.Text;
                oGeoTagDataBase.Location            = this.txtLocation.Text;
                oGeoTagDataBase.Service_Description = this.txtSerDesc.Text;
                oGeoTagDataBase.Type = this.cmbType.Text;
                oGeoTagDataBase.Plot_Plan_Document_Number      = this.txtPlotPlan.Text;
                oGeoTagDataBase.Detail_Drawing_Document_Number = this.txtDetailDwg.Text;
                oGeoTagDataBase.Construction_Month             = this.dateTimePickerMon.Text;
                oGeoTagDataBase.Construction_Year            = this.dateTimePickerYear.Text;
                oGeoTagDataBase.Originating_Contractor       = this.txtOriContractor.Text;
                oGeoTagDataBase.Document_Number              = this.txtDocNo.Text;
                oGeoTagDataBase.Material_Main                = this.cmbMaterial.Text;
                oGeoTagDataBase.Procument_Package_Number     = this.txtProcumentPkg.Text;
                oGeoTagDataBase.Contract_Package_Number      = this.txtContractPkgNo.Text;
                oGeoTagDataBase.Construction_Contractor_Name = this.txtConstrContractor.Text;
                oGeoTagDataBase.Construction_Specification_Document_Number = this.txtConstrSpec.Text;

                if (oGeoTagDataBase is Pond)
                {
                    (oGeoTagDataBase as Pond).Supplier_Name     = this.txt17.Text;
                    (oGeoTagDataBase as Pond).Design_Capacity   = this.txt19.Text;
                    (oGeoTagDataBase as Pond).Fluid_Description = this.txt16.Text;
                    (oGeoTagDataBase as Pond).Max_Fluid_Level   = this.txt20.Text;
                    (oGeoTagDataBase as Pond).Supplier_Reference_Drawing_Doc_Number = this.txt18.Text;
                }

                if (oGeoTagDataBase is Road)
                {
                    (oGeoTagDataBase as Road).Number_of_Lanes = this.txt16.Text;
                }

                if (oGeoTagDataBase is OpenChannel)
                {
                    (oGeoTagDataBase as OpenChannel).Fluid_Description = this.txt16.Text;
                }

                BCOM.CellElement oCel = null;

                BCOM.ElementEnumerator oEnum = AddInMain.ComApp.ActiveModelReference.GetSelectedElements();

                BCOM.Element[] oEleSet = oEnum.BuildArrayFromContents();

                if (oEleSet.Length < 1)
                {
                    return(false);
                }

                //WS: if a tagged celll is selected.
                if (oEleSet.Length == 1)
                {
                    if (oEleSet[0].IsCellElement())
                    {
                        if (oEleSet[0].AsCellElement().Name == "Embankment" || oEleSet[0].AsCellElement().Name == "RetainWall" ||
                            oEleSet[0].AsCellElement().Name == "Pond" || oEleSet[0].AsCellElement().Name == "Road" ||
                            oEleSet[0].AsCellElement().Name == "OpenChannel" || oEleSet[0].AsCellElement().Name == "Dike")
                        {
                            oCel = oEleSet[0].AsCellElement();
                        }
                    }
                }
                else //WS: when more than 1 elements selected.
                {
                    oCel = GroupGeoTagCell(strClassName);
                }

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

                AttachInstanceAndValues(oCel, strClassName, oGeoTagDataBase);

                retVal = true;
            }
            catch (Exception)
            {
                throw new Exception("Unexpected error:  GeoTag.ApplyTagFromUI2Selection");
            }

            return(retVal);
        }