Compare commits

...

50 Commits
1.0.2 ... 2.0.0

Author SHA1 Message Date
hrxiang
23fa27d2cc Update README.md 2022-02-25 15:15:53 +08:00
hrxiang
6a1dc1f62a Update README.md 2022-02-25 15:13:38 +08:00
hrxiang
07212474fe Update README.md 2022-02-25 15:11:28 +08:00
hrxiang
8655088af6 Fix bug 2022-02-25 14:53:25 +08:00
hrxiang
b7aa083f48 Fix bug 2022-02-25 09:10:31 +08:00
hrxiang
514fb53eca Fix bug 2022-02-24 17:01:40 +08:00
hrxiang
9345c6465a Fix bug 2022-02-23 14:02:24 +08:00
hrxiang
b05e68355e new version sdk 2022-02-21 18:39:47 +08:00
hrxiang
3746652552 new version sdk 2022-02-21 18:31:18 +08:00
hrxiang
e323eea8cd new version sdk 2022-02-21 17:29:10 +08:00
hrxiang
f111d0c69e new version sdk 2022-02-21 16:15:08 +08:00
hrxiang
ba661a516e new version sdk 2022-02-21 16:15:03 +08:00
hrxiang
43016d5e86 new version sdk 2022-02-21 15:37:19 +08:00
hrxiang
4c43d54a1a new version sdk 2022-02-21 15:11:27 +08:00
hrxiang
b71cd22dce new version sdk 2022-02-19 14:03:45 +08:00
hrxiang
f3261d2ce4 new_version1 2022-02-16 15:36:37 +08:00
hrxiang
cd0865853b Update sdk maven url 2022-01-21 17:21:33 +08:00
hrxiang
3b01a700c9 Update sdk maven url 2022-01-21 17:20:01 +08:00
hrxiang
74b3747f23 Update README.zh-cn.md 2022-01-04 17:56:14 +08:00
hrxiang
24ff862476 Fix bug 2022-01-04 17:39:18 +08:00
hrxiang
64e91c8294 Create stale.yml 2022-01-04 16:04:41 +08:00
hrxiang
b33d047cfb Delete dart.yml 2022-01-04 15:57:16 +08:00
hrxiang
2e52435041 Create dart.yml 2022-01-04 15:53:13 +08:00
hrxiang
e0071ca84b Delete dart.yml 2022-01-04 15:52:51 +08:00
hrxiang
9d2e2ee0b2 Delete objective-c-xcode.yml 2022-01-04 15:51:46 +08:00
hrxiang
7d7cf6ddfa Create dart.yml 2022-01-04 15:51:36 +08:00
hrxiang
4df97754c7 Create objective-c-xcode.yml 2022-01-04 15:49:36 +08:00
hrxiang
5555cfde7c Add bug template 2022-01-04 15:27:59 +08:00
hrxiang
39988a49cf Add bug template 2022-01-04 15:23:53 +08:00
hrxiang
9c176068c4 Fix ios message progress bug 2022-01-04 11:27:01 +08:00
hrxiang
6ef237b1e6 Modify parameter naming 2022-01-04 10:08:35 +08:00
hrxiang
ad3923e121 Upgrade 2021-12-31 09:49:23 +08:00
hrxiang
0607cd2928 Upgrade 2021-12-21 17:36:56 +08:00
hrxiang
760d65b9d0 Upgrade 2021-12-20 17:31:34 +08:00
hrxiang
46e28651ea Update README.md 2021-12-20 17:22:15 +08:00
hrxiang
b6aea0f7e1 Upgrade 2021-12-20 14:55:32 +08:00
hrxiang
e1a6ab3c79 Upgrade 2021-12-20 14:49:31 +08:00
hrxiang
c16fe12ca6 Update README.md 2021-12-15 16:39:21 +08:00
hrxiang
0fbfc70ef1 Upgrade 2021-12-15 14:55:47 +08:00
hrxiang
603188d98a Update README.md 2021-12-13 10:58:58 +08:00
hrxiang
51667e19d7 Fix bug 2021-12-13 10:21:27 +08:00
hrxiang
862bf46ace Fix bug 2021-12-10 18:16:41 +08:00
hrxiang
744268371f Fix bug 2021-12-10 16:51:28 +08:00
hrxiang
aa05465509 Update SDK to 1.3.4 2021-12-09 16:18:01 +08:00
hrxiang
790dbafd6b Update SDK to 1.2.9 2021-12-06 10:42:55 +08:00
hrxiang
6527295f1f Update SDK to 1.2.8 2021-12-01 09:40:01 +08:00
hrxiang
27293375a4 Update SDK to 1.2.1 2021-11-25 17:58:07 +08:00
hrxiang
401255df6e Update SDK to 1.2.0 2021-11-25 09:57:27 +08:00
hrxiang
7fdc262b5f Merge remote-tracking branch 'origin/fix-ios-simulator' 2021-11-24 11:14:24 +08:00
hrxiang
579e3dd236 Update SDK to 1.2.0 2021-11-24 11:12:06 +08:00
80 changed files with 5017 additions and 5371 deletions

44
.github/ISSUE_TEMPLATE/bug-report.md vendored Normal file
View File

@@ -0,0 +1,44 @@
---
name: Bug report (BUG模板)
about: Create a bug report helping us fix it. (创建一个 BUG 报告以帮助我们进行修复)
title: "[BUG] Error with something"
labels: await investigate, bug
---
**Describe the bug**
<!-- A clear and concise description of what the bug is.
请用精炼的语句准确描述你遇到的BUG。-->
**How to reproduce**
<!-- Please **provide a minimum demo** rather than
**a full project or a incomplete pages**.
Otherwise, we won't accept your request.
请提供一个 **最简单的 demo** 用于复现,而不要提供 **整个项目或者不完整的页面**
否则我们不会受理你的问题。-->
Steps to reproduce the behavior:
<!-- 描述复现步骤 -->
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. Error occurred.
**Expected behavior**
<!-- A clear and concise description of what you expected to happen.
描述你期望的行为。-->
**Screenshots (If contains)**
<!-- If applicable, add screenshots to help explain your problem.
如有相关截图,请提供它们用于解释问题所在。-->
**Version information**
- Device: *e.g. iPhone X*
- OS: *e.g. iOS 14.7.1*
- Package Version: *e.g. v1.0.9*
- Flutter Version: *e.g. v2.8.0*
**Additional context**
<!-- Add any other context about the problem here.
在此提供更多的内容。 -->

View File

@@ -0,0 +1,30 @@
---
name: Feature request (功能请求)
about: Request a new feature that the package didn't include. (请求一个依赖并未包含的功能)
title: "[Feature] Request a feature with something"
labels: feature, await investigate
---
**Version information**
- Device: *e.g. iPhone X*
- OS: *e.g. iOS 14.7.1*
- Package Version: *e.g. v1.0.9*
- Flutter Version: *e.g. v2.8.0*
**Is your feature request related to a problem?**
<!-- A clear and concise description if it's related to an exist problem.
如果与已有问题有关,请准确描述。-->
**Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen.
描述你期望的解决方案。-->
**Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions
or features you've considered.
准确描述其他解决方案或你的疑虑。 -->
**Additional context**
<!-- Add any other context or screenshots about the feature request here.
请提供任何你认为需要的附加内容。 -->

27
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests
on:
schedule:
- cron: '33 21 * * *'
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Stale issue message'
stale-pr-message: 'Stale pull request message'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'

461
.idea/dbnavigator.xml generated Normal file
View File

@@ -0,0 +1,461 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DBNavigator.Project.DataEditorManager">
<record-view-column-sorting-type value="BY_INDEX" />
<value-preview-text-wrapping value="false" />
<value-preview-pinned value="false" />
</component>
<component name="DBNavigator.Project.DataExportManager">
<export-instructions>
<create-header value="true" />
<friendly-headers value="false" />
<quote-values-containing-separator value="true" />
<quote-all-values value="false" />
<value-separator value="" />
<file-name value="" />
<file-location value="" />
<scope value="GLOBAL" />
<destination value="FILE" />
<format value="EXCEL" />
<charset value="UTF-8" />
</export-instructions>
</component>
<component name="DBNavigator.Project.DatabaseBrowserManager">
<autoscroll-to-editor value="false" />
<autoscroll-from-editor value="true" />
<show-object-properties value="true" />
<loaded-nodes />
</component>
<component name="DBNavigator.Project.DatabaseFileManager">
<open-files />
</component>
<component name="DBNavigator.Project.EditorStateManager">
<last-used-providers />
</component>
<component name="DBNavigator.Project.ExecutionManager">
<retain-sticky-names value="false" />
</component>
<component name="DBNavigator.Project.MethodExecutionManager">
<method-browser />
<execution-history>
<group-entries value="true" />
<execution-inputs />
</execution-history>
<argument-values-cache />
</component>
<component name="DBNavigator.Project.ObjectDependencyManager">
<last-used-dependency-type value="INCOMING" />
</component>
<component name="DBNavigator.Project.ObjectQuickFilterManager">
<last-used-operator value="EQUAL" />
<filters />
</component>
<component name="DBNavigator.Project.ParserDiagnosticsManager">
<diagnostics-history />
</component>
<component name="DBNavigator.Project.ScriptExecutionManager" clear-outputs="true">
<recently-used-interfaces />
</component>
<component name="DBNavigator.Project.Settings">
<connections />
<browser-settings>
<general>
<display-mode value="TABBED" />
<navigation-history-size value="100" />
<show-object-details value="false" />
</general>
<filters>
<object-type-filter>
<object-type name="SCHEMA" enabled="true" />
<object-type name="USER" enabled="true" />
<object-type name="ROLE" enabled="true" />
<object-type name="PRIVILEGE" enabled="true" />
<object-type name="CHARSET" enabled="true" />
<object-type name="TABLE" enabled="true" />
<object-type name="VIEW" enabled="true" />
<object-type name="MATERIALIZED_VIEW" enabled="true" />
<object-type name="NESTED_TABLE" enabled="true" />
<object-type name="COLUMN" enabled="true" />
<object-type name="INDEX" enabled="true" />
<object-type name="CONSTRAINT" enabled="true" />
<object-type name="DATASET_TRIGGER" enabled="true" />
<object-type name="DATABASE_TRIGGER" enabled="true" />
<object-type name="SYNONYM" enabled="true" />
<object-type name="SEQUENCE" enabled="true" />
<object-type name="PROCEDURE" enabled="true" />
<object-type name="FUNCTION" enabled="true" />
<object-type name="PACKAGE" enabled="true" />
<object-type name="TYPE" enabled="true" />
<object-type name="TYPE_ATTRIBUTE" enabled="true" />
<object-type name="ARGUMENT" enabled="true" />
<object-type name="DIMENSION" enabled="true" />
<object-type name="CLUSTER" enabled="true" />
<object-type name="DBLINK" enabled="true" />
</object-type-filter>
</filters>
<sorting>
<object-type name="COLUMN" sorting-type="NAME" />
<object-type name="FUNCTION" sorting-type="NAME" />
<object-type name="PROCEDURE" sorting-type="NAME" />
<object-type name="ARGUMENT" sorting-type="POSITION" />
</sorting>
<default-editors>
<object-type name="VIEW" editor-type="SELECTION" />
<object-type name="PACKAGE" editor-type="SELECTION" />
<object-type name="TYPE" editor-type="SELECTION" />
</default-editors>
</browser-settings>
<navigation-settings>
<lookup-filters>
<lookup-objects>
<object-type name="SCHEMA" enabled="true" />
<object-type name="USER" enabled="false" />
<object-type name="ROLE" enabled="false" />
<object-type name="PRIVILEGE" enabled="false" />
<object-type name="CHARSET" enabled="false" />
<object-type name="TABLE" enabled="true" />
<object-type name="VIEW" enabled="true" />
<object-type name="MATERIALIZED VIEW" enabled="true" />
<object-type name="INDEX" enabled="true" />
<object-type name="CONSTRAINT" enabled="true" />
<object-type name="DATASET TRIGGER" enabled="true" />
<object-type name="DATABASE TRIGGER" enabled="true" />
<object-type name="SYNONYM" enabled="false" />
<object-type name="SEQUENCE" enabled="true" />
<object-type name="PROCEDURE" enabled="true" />
<object-type name="FUNCTION" enabled="true" />
<object-type name="PACKAGE" enabled="true" />
<object-type name="TYPE" enabled="true" />
<object-type name="DIMENSION" enabled="false" />
<object-type name="CLUSTER" enabled="false" />
<object-type name="DBLINK" enabled="true" />
</lookup-objects>
<force-database-load value="false" />
<prompt-connection-selection value="true" />
<prompt-schema-selection value="true" />
</lookup-filters>
</navigation-settings>
<dataset-grid-settings>
<general>
<enable-zooming value="true" />
<enable-column-tooltip value="true" />
</general>
<sorting>
<nulls-first value="true" />
<max-sorting-columns value="4" />
</sorting>
<tracking-columns>
<columnNames value="" />
<visible value="true" />
<editable value="false" />
</tracking-columns>
</dataset-grid-settings>
<dataset-editor-settings>
<text-editor-popup>
<active value="false" />
<active-if-empty value="false" />
<data-length-threshold value="100" />
<popup-delay value="1000" />
</text-editor-popup>
<values-actions-popup>
<show-popup-button value="true" />
<element-count-threshold value="1000" />
<data-length-threshold value="250" />
</values-actions-popup>
<general>
<fetch-block-size value="100" />
<fetch-timeout value="30" />
<trim-whitespaces value="true" />
<convert-empty-strings-to-null value="true" />
<select-content-on-cell-edit value="true" />
<large-value-preview-active value="true" />
</general>
<filters>
<prompt-filter-dialog value="true" />
<default-filter-type value="BASIC" />
</filters>
<qualified-text-editor text-length-threshold="300">
<content-types>
<content-type name="Text" enabled="true" />
<content-type name="Properties" enabled="true" />
<content-type name="XML" enabled="true" />
<content-type name="DTD" enabled="true" />
<content-type name="HTML" enabled="true" />
<content-type name="XHTML" enabled="true" />
<content-type name="Java" enabled="true" />
<content-type name="SQL" enabled="true" />
<content-type name="PL/SQL" enabled="true" />
<content-type name="JSON" enabled="true" />
<content-type name="JSON5" enabled="true" />
<content-type name="Groovy" enabled="true" />
<content-type name="AIDL" enabled="true" />
<content-type name="YAML" enabled="true" />
<content-type name="Manifest" enabled="true" />
</content-types>
</qualified-text-editor>
<record-navigation>
<navigation-target value="VIEWER" />
</record-navigation>
</dataset-editor-settings>
<code-editor-settings>
<general>
<show-object-navigation-gutter value="false" />
<show-spec-declaration-navigation-gutter value="true" />
<enable-spellchecking value="true" />
<enable-reference-spellchecking value="false" />
</general>
<confirmations>
<save-changes value="false" />
<revert-changes value="true" />
</confirmations>
</code-editor-settings>
<code-completion-settings>
<filters>
<basic-filter>
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
<filter-element type="RESERVED_WORD" id="function" selected="true" />
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
<filter-element type="OBJECT" id="schema" selected="true" />
<filter-element type="OBJECT" id="role" selected="true" />
<filter-element type="OBJECT" id="user" selected="true" />
<filter-element type="OBJECT" id="privilege" selected="true" />
<user-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="false" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</user-schema>
<public-schema>
<filter-element type="OBJECT" id="table" selected="false" />
<filter-element type="OBJECT" id="view" selected="false" />
<filter-element type="OBJECT" id="materialized view" selected="false" />
<filter-element type="OBJECT" id="index" selected="false" />
<filter-element type="OBJECT" id="constraint" selected="false" />
<filter-element type="OBJECT" id="trigger" selected="false" />
<filter-element type="OBJECT" id="synonym" selected="false" />
<filter-element type="OBJECT" id="sequence" selected="false" />
<filter-element type="OBJECT" id="procedure" selected="false" />
<filter-element type="OBJECT" id="function" selected="false" />
<filter-element type="OBJECT" id="package" selected="false" />
<filter-element type="OBJECT" id="type" selected="false" />
<filter-element type="OBJECT" id="dimension" selected="false" />
<filter-element type="OBJECT" id="cluster" selected="false" />
<filter-element type="OBJECT" id="dblink" selected="false" />
</public-schema>
<any-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</any-schema>
</basic-filter>
<extended-filter>
<filter-element type="RESERVED_WORD" id="keyword" selected="true" />
<filter-element type="RESERVED_WORD" id="function" selected="true" />
<filter-element type="RESERVED_WORD" id="parameter" selected="true" />
<filter-element type="RESERVED_WORD" id="datatype" selected="true" />
<filter-element type="RESERVED_WORD" id="exception" selected="true" />
<filter-element type="OBJECT" id="schema" selected="true" />
<filter-element type="OBJECT" id="user" selected="true" />
<filter-element type="OBJECT" id="role" selected="true" />
<filter-element type="OBJECT" id="privilege" selected="true" />
<user-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</user-schema>
<public-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</public-schema>
<any-schema>
<filter-element type="OBJECT" id="table" selected="true" />
<filter-element type="OBJECT" id="view" selected="true" />
<filter-element type="OBJECT" id="materialized view" selected="true" />
<filter-element type="OBJECT" id="index" selected="true" />
<filter-element type="OBJECT" id="constraint" selected="true" />
<filter-element type="OBJECT" id="trigger" selected="true" />
<filter-element type="OBJECT" id="synonym" selected="true" />
<filter-element type="OBJECT" id="sequence" selected="true" />
<filter-element type="OBJECT" id="procedure" selected="true" />
<filter-element type="OBJECT" id="function" selected="true" />
<filter-element type="OBJECT" id="package" selected="true" />
<filter-element type="OBJECT" id="type" selected="true" />
<filter-element type="OBJECT" id="dimension" selected="true" />
<filter-element type="OBJECT" id="cluster" selected="true" />
<filter-element type="OBJECT" id="dblink" selected="true" />
</any-schema>
</extended-filter>
</filters>
<sorting enabled="true">
<sorting-element type="RESERVED_WORD" id="keyword" />
<sorting-element type="RESERVED_WORD" id="datatype" />
<sorting-element type="OBJECT" id="column" />
<sorting-element type="OBJECT" id="table" />
<sorting-element type="OBJECT" id="view" />
<sorting-element type="OBJECT" id="materialized view" />
<sorting-element type="OBJECT" id="index" />
<sorting-element type="OBJECT" id="constraint" />
<sorting-element type="OBJECT" id="trigger" />
<sorting-element type="OBJECT" id="synonym" />
<sorting-element type="OBJECT" id="sequence" />
<sorting-element type="OBJECT" id="procedure" />
<sorting-element type="OBJECT" id="function" />
<sorting-element type="OBJECT" id="package" />
<sorting-element type="OBJECT" id="type" />
<sorting-element type="OBJECT" id="dimension" />
<sorting-element type="OBJECT" id="cluster" />
<sorting-element type="OBJECT" id="dblink" />
<sorting-element type="OBJECT" id="schema" />
<sorting-element type="OBJECT" id="role" />
<sorting-element type="OBJECT" id="user" />
<sorting-element type="RESERVED_WORD" id="function" />
<sorting-element type="RESERVED_WORD" id="parameter" />
</sorting>
<format>
<enforce-code-style-case value="true" />
</format>
</code-completion-settings>
<execution-engine-settings>
<statement-execution>
<fetch-block-size value="100" />
<execution-timeout value="20" />
<debug-execution-timeout value="600" />
<focus-result value="false" />
<prompt-execution value="false" />
</statement-execution>
<script-execution>
<command-line-interfaces />
<execution-timeout value="300" />
</script-execution>
<method-execution>
<execution-timeout value="30" />
<debug-execution-timeout value="600" />
<parameter-history-size value="10" />
</method-execution>
</execution-engine-settings>
<operation-settings>
<transactions>
<uncommitted-changes>
<on-project-close value="ASK" />
<on-disconnect value="ASK" />
<on-autocommit-toggle value="ASK" />
</uncommitted-changes>
<multiple-uncommitted-changes>
<on-commit value="ASK" />
<on-rollback value="ASK" />
</multiple-uncommitted-changes>
</transactions>
<session-browser>
<disconnect-session value="ASK" />
<kill-session value="ASK" />
<reload-on-filter-change value="false" />
</session-browser>
<compiler>
<compile-type value="KEEP" />
<compile-dependencies value="ASK" />
<always-show-controls value="false" />
</compiler>
<debugger>
<debugger-type value="ASK" />
<use-generic-runners value="true" />
</debugger>
</operation-settings>
<ddl-file-settings>
<extensions>
<mapping file-type-id="VIEW" extensions="vw" />
<mapping file-type-id="TRIGGER" extensions="trg" />
<mapping file-type-id="PROCEDURE" extensions="prc" />
<mapping file-type-id="FUNCTION" extensions="fnc" />
<mapping file-type-id="PACKAGE" extensions="pkg" />
<mapping file-type-id="PACKAGE_SPEC" extensions="pks" />
<mapping file-type-id="PACKAGE_BODY" extensions="pkb" />
<mapping file-type-id="TYPE" extensions="tpe" />
<mapping file-type-id="TYPE_SPEC" extensions="tps" />
<mapping file-type-id="TYPE_BODY" extensions="tpb" />
</extensions>
<general>
<lookup-ddl-files value="true" />
<create-ddl-files value="false" />
<synchronize-ddl-files value="true" />
<use-qualified-names value="false" />
<make-scripts-rerunnable value="true" />
</general>
</ddl-file-settings>
<general-settings>
<regional-settings>
<date-format value="MEDIUM" />
<number-format value="UNGROUPED" />
<locale value="SYSTEM_DEFAULT" />
<use-custom-formats value="false" />
</regional-settings>
<environment>
<environment-types>
<environment-type id="development" name="Development" description="Development environment" color="-2430209/-12296320" readonly-code="false" readonly-data="false" />
<environment-type id="integration" name="Integration" description="Integration environment" color="-2621494/-12163514" readonly-code="true" readonly-data="false" />
<environment-type id="production" name="Production" description="Productive environment" color="-11574/-10271420" readonly-code="true" readonly-data="true" />
<environment-type id="other" name="Other" description="" color="-1576/-10724543" readonly-code="false" readonly-data="false" />
</environment-types>
<visibility-settings>
<connection-tabs value="true" />
<dialog-headers value="true" />
<object-editor-tabs value="true" />
<script-editor-tabs value="false" />
<execution-result-tabs value="true" />
</visibility-settings>
</environment>
</general-settings>
</component>
<component name="DBNavigator.Project.StatementExecutionManager">
<execution-variables />
</component>
</project>

View File

@@ -1,6 +1,47 @@
## 2.0.0+1
1.Fix multi-terminal synchronization bug fix for retracted messages </br>
2.Fix sending picture flashback bug </br>
3.Fix other bug
## 2.0.0
1.Refactor mobile sdk, server sdk (2022-2-21)
## 1.1.1
1.Update sdk maven url
## 1.1.0
1.Fix the problem of missing id in ios message progress
## 1.0.9
1.Upgrade sdk to 1.4.5.
## 1.0.8
1.Upgrade sdk to 1.4.4. </br>
2.New and changed conversation return changed data and no longer return all data. </br>
3.New conversation paging method.
## 1.0.7
Upgrade sdk to 1.3.4 </br>
New add method setConversationRecvMessageOpt and getConversationRecvMessageOpt
## 1.0.6
Upgrade sdk to 1.2.9
## 1.0.5
Upgrade sdk to 1.2.8
## 1.0.4 ## 1.0.4
New add clear c2c message and group message </bar> New add clear c2c message and group message </br>
Update sdk to 1.1.9 Update sdk to 1.1.9
## 1.0.3 ## 1.0.3

294
README.md
View File

@@ -1,303 +1,23 @@
# flutter_openim_sdk # flutter_openim_sdk
[![pub package](https://img.shields.io/pub/v/flutter_openim_sdk.svg)](https://pub.flutter-io.cn/packages/flutter_openim_sdk)
[![Generic badge](https://img.shields.io/badge/platform-android%20|%20ios%20-blue.svg)](https://pub.dev/packages/flutter_openim_sdk)
[![GitHub license](https://img.shields.io/github/license/OpenIMSDK/Open-IM-SDK-Flutter)](https://github.com/OpenIMSDK/Open-IM-SDK-Flutter/blob/main/LICENSE)
### [Download demo](https://github.com/OpenIMSDK/Open-IM-Flutter-Demo.git) A flutter im plugin for android and ios.
### [flutter_openim_widget](https://github.com/hrxiang/flutter_openim_widget.git) #### [中文文档](README.zh-cn.md) | [demo(体验app源代码)](https://github.com/OpenIMSDK/Open-IM-Flutter-Demo.git) | [widget(聊天UI库)](https://github.com/hrxiang/flutter_openim_widget.git)
[![Chinese](https://img.shields.io/badge/Language-Chinese-blueviolet?style=for-the-badge)](README.zh-cn.md) ![Android](https://www.pgyer.com/app/qrcode/OpenIM)
A flutter IM plugin for android and ios.
## Getting Started ## Getting Started
#### 1Add dependency in yaml #### 1Add dependency in yaml
flutter_openim_sdk: ^1.0.4 flutter_openim_sdk: latest
#### 2Import package #### 2Import package
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
#### 3 Init config
```
// Initialize SDK
OpenIM.iMManager
..initSDK(
platform: IMPlatform.ios,
ipApi: 'Api interface address',
ipWs: 'WebSocket address',
dbPath: 'Database directory',
listener: OnInitSDKListener(
connecting: () {},
connectFailed: (code, error) {},
connectSuccess: () {},
kickedOffline: () {},
userSigExpired: () {},
selfInfoUpdated: (user) {},
),
)
// Add message listener (remove when not in use)
..messageManager.addAdvancedMsgListener(OnAdvancedMsgListener(
recvMessageRevoked: (id) {},
recvC2CReadReceipt: (list) {},
recvNewMessage: (msg) {},
))
// Set up message sending progress listener
..messageManager.setMsgSendProgressListener(OnMsgSendProgressListener(
progressCallback: (id, progress) {},
))
// Set up friend relationship listener
..friendshipManager.setFriendshipListener(OnFriendshipListener(
blackListAdd: (u) {},
blackListDeleted: (u) {},
friendApplicationListAccept: (u) {},
friendApplicationListAdded: (u) {},
friendApplicationListDeleted: (u) {},
friendApplicationListReject: (u) {},
friendInfoChanged: (u) {},
friendListAdded: (u) {},
friendListDeleted: (u) {},
))
// Set up conversation listener
..conversationManager.setConversationListener(OnConversationListener(
conversationChanged: (list) {},
newConversation: (list) {},
totalUnreadMsgCountChanged: (count) {},
syncServerFailed: () {},
syncServerFinish: () {},
syncServerStart: () {},
))
// Set up group listener
..groupManager.setGroupListener(OnGroupListener(
applicationProcessed: (groupId, opUser, agreeOrReject, opReason) {},
groupCreated: (groupId) {},
groupInfoChanged: (groupId, info) {},
memberEnter: (groupId, list) {},
memberInvited: (groupId, opUser, list) {},
memberKicked: (groupId, opUser, list) {},
memberLeave: (groupId, info) {},
receiveJoinApplication: (groupId, info, opReason) {},
));
```
#### 4 Log in
```
OpenIM.iMManager.login(uid: uid, token: token).then((value){
// login successful
});
```
#### 5Get a list of conversations
```
OpenIM.iMManager.conversationManager.getAllConversationList().then((list) {
// Return to the conversation list
});
```
#### 6Get contact list
```
OpenIM.iMManager.friendshipManager.getFriendList().then((list) {
// Return to friends list
});
```
#### 7Get chat history
```
List<Message> chatMsgList = List.empty(growable: true);
/// Custom message listener, the arrival of a new message will trigger the onNewMessage method callback
class CustomAdvancedMsgListener extends AdvancedMsgListener {
final ValueChanged<Message>? onNewMessage;
CustomAdvancedMsgListener({
this.onNewMessage,
});
@override
void onRecvNewMessage(Message msg) {
if (null != onNewMessage) onNewMessage!(msg);
}
}
```
- History news
```
// If userID is not null and groupID is null, get a single chat message list
// If the userID is null and the groupID is not null, get a group chat message list
OpenIM.iMManager.messageManager.getHistoryMessageList(
userID: uid,//User id
startMsg: startMsg,//Last message, take chatMsgList[0]
groupID: gid,//Group id
count: 12,//Page Size
)
.then((list) => chatMsgList.addAll(list));
```
- New news
```
// Create a message listener
// After entering the chat page, you need to listen for new messages and then render the UI
// Each chat window has a unique uid (user id) or gid (group id)
// Determine whether the received message belongs to the current window according to uid or gid
var msgListener = CustomAdvancedMsgListener(onNewMessage: (message) {
// If the sender user id is equal to the user id of the current chat page,
// or the group id is equal to the current group id of the current chat page
if (message.sendID == uid || message.groupID == gid) {
if (!chatMsgList.contains(message)) {
// New message in current chat page
chatMsgList.add(event.message);
}
}
});
// Add message listener
OpenIM.iMManager.messageManager.addAdvancedMsgListener(msgListener);
// Remove message monitoring
// After adding a message listener, if the page disposes, please remove the listener
// OpenIM.iMManager.messageManager.removeAdvancedMsgListener(msgListener);
```
#### 8Send a message
```
// Create message
var message = await OpenIM.iMManager.messageManager.createTextMessage(
text: 'I am the content of the message',
);
// Send
OpenIM.iMManager.messageManager.sendMessage(
message: message,
onlineUserOnly: false,
userID: uid, // Single chat value is not null
groupID: gid, // The group chat value is not null
).then((v) {
// Sent successfully
}).catchError((e){
// Failed to send
});
```
#### 9Sign out
```
OpenIM.iMManager.logout();
```
#### OpenIM.iMManager
| method | description |
| ---------------- | ------------------------------- |
| initSDK | Initialize SDK |
| unInitSDK | |
| login | Log in |
| logout | Sign out |
| getLoginStatus | Login status |
| getLoginUid | Current user id |
| getLoginUserInfo | Current user information |
| setSelfInfo | Modify current user information |
| getUsersInfo | Get user information by user id |
| forceReConn | Force reconnection |
#### OpenIM.iMManager.conversationManager
| method | description |
| ----------------------- | --------------------------- |
| setConversationListener | Listener |
| getAllConversationList | Get all conversation |
| getSingleConversation | Get a single conversation |
| getMultipleConversation | Get multiple conversation |
| deleteConversation | Delete conversation |
| setConversationDraft | Set conversation draftText |
| pinConversation | Top conversation |
#### OpenIM.iMManager.friendshipManager
| method | description |
| ------------------------ | --------------------------- |
| setFriendshipListener | Listener |
| getFriendsInfo | Get friend information |
| addFriend | Add friends |
| getFriendApplicationList | Get friend application list |
| getFriendList | Get friends list |
| setFriendInfo | Edit friend notes |
| addToBlackList | Add to blacklist |
| getBlackList | Get blacklist list |
| deleteFromBlackList | Remove from blacklist |
| checkFriend | Check friendship |
| deleteFromFriendList | Remove friend |
| acceptFriendApplication | Accept friend application |
| refuseFriendApplication | Reject friend application |
#### OpenIM.iMManager.messageManager
| method | description |
| ------------------------------------------- | --------------------------------- |
| addAdvancedMsgListener | Add message listener |
| removeAdvancedMsgListener | Remove message listener |
| setMsgSendProgressListener | Message sending progress listener |
| sendMessage | Send a message |
| getHistoryMessageList | Get history news |
| revokeMessage | Revoke message |
| deleteMessageFromLocalStorage | Delete message |
| insertSingleMessageToLocalStorage | Insert message |
| findMessages | Query the message by id |
| markSingleMessageHasRead | Mark single chat messages as read |
| markGroupMessageHasRead | Mark group chat messages as read |
| <font color=red>markC2CMessageAsRead</font> | Mark c2c message as read |
| <font color=red>typingStatusUpdate</font> | Typing prompt |
| createTextMessage | Create text message |
| createTextAtMessage | Create @ message |
| createImageMessage | Create picture message |
| createSoundMessage | Create voice message |
| createVideoMessage | Create video message |
| createFileMessage | Create file message |
| createMergerMessage | Create merge message |
| createForwardMessage | Create a forwarded message |
| getTotalUnreadMsgCount | Get unread message count |
#### OpenIM.iMManager.groupManager
| method | description |
| ----------------------- | ------------------------------- |
| setGroupListener | Listener |
| inviteUserToGroup | Invite into the group |
| kickGroupMember | Remove group members |
| getGroupMembersInfo | Get group member information |
| getGroupMemberList | Get group members |
| getJoinedGroupList | Get joined groups |
| isJoinedGroup | Check you have joined the group |
| createGroup | Create a group |
| setGroupInfo | Set group information |
| getGroupsInfo | Get group information |
| joinGroup | Join group |
| quitGroup | Exit group |
| transferGroupOwner | Group permission transfer |
| getGroupApplicationList | Get group application list |
| acceptGroupApplication | Accept group invitation |
| refuseGroupApplication | Decline group invitation |

File diff suppressed because it is too large Load Diff

View File

@@ -3,35 +3,25 @@ version '1.0'
buildscript { buildscript {
repositories { repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
maven { maven {
allowInsecureProtocol = true allowInsecureProtocol = true
url 'http://47.112.160.66:8081/repository/maven-releases' url 'http://121.37.25.71:8081/repository/maven-releases/'
} }
// maven { url 'https://127.0.0.1:8081/repository/maven-releases' }
google() google()
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.1' classpath 'com.android.tools.build:gradle:3.5.4'
} }
} }
rootProject.allprojects { rootProject.allprojects {
repositories { repositories {
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
maven { maven {
allowInsecureProtocol = true allowInsecureProtocol = true
url 'http://47.112.160.66:8081/repository/maven-releases' url 'http://121.37.25.71:8081/repository/maven-releases/'
} }
// maven { url 'http://127.0.0.1:8081/repository/maven-releases' }
google() google()
mavenCentral() mavenCentral()
} }
@@ -51,5 +41,5 @@ android {
} }
} }
dependencies { dependencies {
implementation 'io.openim:client-sdk:1.1.9@aar' implementation 'io.openim:client-sdk:2.0.4@aar'
} }

View File

@@ -18,6 +18,7 @@ import io.openim.flutter_openim_sdk.manager.FriendshipManager;
import io.openim.flutter_openim_sdk.manager.GroupManager; import io.openim.flutter_openim_sdk.manager.GroupManager;
import io.openim.flutter_openim_sdk.manager.IMManager; import io.openim.flutter_openim_sdk.manager.IMManager;
import io.openim.flutter_openim_sdk.manager.MessageManager; import io.openim.flutter_openim_sdk.manager.MessageManager;
import io.openim.flutter_openim_sdk.manager.UserManager;
/** /**
@@ -31,6 +32,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler
public static MethodChannel channel; public static MethodChannel channel;
private static IMManager imManager; private static IMManager imManager;
private static UserManager userManager;
private static FriendshipManager friendshipManager; private static FriendshipManager friendshipManager;
private static MessageManager messageManager; private static MessageManager messageManager;
private static ConversationManager conversationManager; private static ConversationManager conversationManager;
@@ -41,6 +43,7 @@ public class FlutterOpenimSdkPlugin implements FlutterPlugin, MethodCallHandler
private FlutterOpenimSdkPlugin(Context context) { private FlutterOpenimSdkPlugin(Context context) {
FlutterOpenimSdkPlugin.imManager = new IMManager(); FlutterOpenimSdkPlugin.imManager = new IMManager();
FlutterOpenimSdkPlugin.userManager = new UserManager();
FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager(); FlutterOpenimSdkPlugin.friendshipManager = new FriendshipManager();
FlutterOpenimSdkPlugin.messageManager = new MessageManager(); FlutterOpenimSdkPlugin.messageManager = new MessageManager();
FlutterOpenimSdkPlugin.conversationManager = new ConversationManager(); FlutterOpenimSdkPlugin.conversationManager = new ConversationManager();

View File

@@ -1,52 +0,0 @@
package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnFriendshipListener;
public class FriendshipListener implements OnFriendshipListener {
@Override
public void onBlackListAdd(String s) {
CommonUtil.emitEvent("friendListener", "onBlackListAdd", s);
}
@Override
public void onBlackListDeleted(String s) {
CommonUtil.emitEvent("friendListener", "onBlackListDeleted", s);
}
@Override
public void onFriendApplicationListAccept(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationListAccept", s);
}
@Override
public void onFriendApplicationListAdded(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationListAdded", s);
}
@Override
public void onFriendApplicationListDeleted(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationListDeleted", s);
}
@Override
public void onFriendApplicationListReject(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationListReject", s);
}
@Override
public void onFriendInfoChanged(String s) {
CommonUtil.emitEvent("friendListener", "onFriendInfoChanged", s);
}
@Override
public void onFriendListAdded(String s) {
CommonUtil.emitEvent("friendListener", "onFriendListAdded", s);
}
@Override
public void onFriendListDeleted(String s) {
CommonUtil.emitEvent("friendListener", "onFriendListDeleted", s);
}
}

View File

@@ -1,79 +0,0 @@
package io.openim.flutter_openim_sdk.listener;
import android.util.ArrayMap;
import java.util.HashMap;
import java.util.Map;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnGroupListener;
public class GroupListener implements OnGroupListener {
@Override
public void onApplicationProcessed(String s, String s1, int i, String s2) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
map.put("opUser", s1);
map.put("agreeOrReject", i);
map.put("opReason", s2);
CommonUtil.emitEvent("groupListener", "onApplicationProcessed", map);
}
@Override
public void onGroupCreated(String s) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
CommonUtil.emitEvent("groupListener", "onGroupCreated", map);
}
@Override
public void onGroupInfoChanged(String s, String s1) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
map.put("groupInfo", s1);
CommonUtil.emitEvent("groupListener", "onGroupInfoChanged", map);
}
@Override
public void onMemberEnter(String s, String s1) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
map.put("memberList", s1);
CommonUtil.emitEvent("groupListener", "onMemberEnter", map);
}
@Override
public void onMemberInvited(String s, String s1, String s2) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
map.put("opUser", s1);
map.put("memberList", s2);
CommonUtil.emitEvent("groupListener", "onMemberInvited", map);
}
@Override
public void onMemberKicked(String s, String s1, String s2) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
map.put("opUser", s1);
map.put("memberList", s2);
CommonUtil.emitEvent("groupListener", "onMemberKicked", map);
}
@Override
public void onMemberLeave(String s, String s1) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
map.put("member", s1);
CommonUtil.emitEvent("groupListener", "onMemberLeave", map);
}
@Override
public void onReceiveJoinApplication(String s, String s1, String s2) {
Map<String, Object> map = new ArrayMap<>();
map.put("groupId", s);
map.put("member", s1);
map.put("opReason", s2);
CommonUtil.emitEvent("groupListener", "onReceiveJoinApplication", map);
}
}

View File

@@ -5,15 +5,12 @@ import android.util.ArrayMap;
import java.util.Map; import java.util.Map;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnAdvancedMsgListener;
public class AdvancedMsgListener implements OnAdvancedMsgListener { public class OnAdvancedMsgListener implements open_im_sdk_callback.OnAdvancedMsgListener {
// final Map<String, String> values = new HashMap<>();
private final String id; private final String id;
public AdvancedMsgListener(String listenerId) { public OnAdvancedMsgListener(String listenerId) {
this.id = listenerId; this.id = listenerId;
// this.values.put("id", listenerId);
} }
@Override @Override

View File

@@ -1,28 +1,25 @@
package io.openim.flutter_openim_sdk.listener; package io.openim.flutter_openim_sdk.listener;
import io.flutter.Log;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Base; import open_im_sdk_callback.Base;
public class BaseListener implements Base { public class OnBaseListener implements Base {
MethodChannel.Result result; MethodChannel.Result result;
public BaseListener(MethodChannel.Result result) { public OnBaseListener(MethodChannel.Result result) {
this.result = result; this.result = result;
} }
@Override @Override
public void onError(long l, String s) { public void onError(int l, String s) {
Log.e("F-OpenIMSD(callback)", s);
CommonUtil.runMainThreadReturnError(result, l, s, null); CommonUtil.runMainThreadReturnError(result, l, s, null);
} }
@Override @Override
public void onSuccess(String s) { public void onSuccess(String s) {
Log.i("F-OpenIMSDK(callback)", s);
CommonUtil.runMainThreadReturn(result, s); CommonUtil.runMainThreadReturn(result, s);
} }
} }

View File

@@ -0,0 +1,34 @@
package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
public class OnConnListener implements open_im_sdk_callback.OnConnListener {
@Override
public void onConnectFailed(int i, String s) {
CommonUtil.emitEvent("connectListener", "onConnectFailed", i, s, null);
}
@Override
public void onConnectSuccess() {
CommonUtil.emitEvent("connectListener", "onConnectSuccess", null);
}
@Override
public void onConnecting() {
CommonUtil.emitEvent("connectListener", "onConnecting", null);
}
@Override
public void onKickedOffline() {
CommonUtil.emitEvent("connectListener", "onKickedOffline", null);
}
@Override
public void onUserTokenExpired() {
CommonUtil.emitEvent("connectListener", "onUserTokenExpired", null);
}
}

View File

@@ -1,10 +1,9 @@
package io.openim.flutter_openim_sdk.listener; package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnConversationListener;
public class ConversationListener implements OnConversationListener {
public class OnConversationListener implements open_im_sdk_callback.OnConversationListener {
@Override @Override
public void onConversationChanged(String s) { public void onConversationChanged(String s) {

View File

@@ -0,0 +1,51 @@
package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
public class OnFriendshipListener implements open_im_sdk_callback.OnFriendshipListener {
@Override
public void onBlackAdded(String s) {
CommonUtil.emitEvent("friendListener", "onBlacklistAdded", s);
}
@Override
public void onBlackDeleted(String s) {
CommonUtil.emitEvent("friendListener", "onBlacklistDeleted", s);
}
@Override
public void onFriendAdded(String s) {
CommonUtil.emitEvent("friendListener", "onFriendAdded", s);
}
@Override
public void onFriendApplicationAccepted(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationAccepted", s);
}
@Override
public void onFriendApplicationAdded(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationAdded", s);
}
@Override
public void onFriendApplicationDeleted(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationDeleted", s);
}
@Override
public void onFriendApplicationRejected(String s) {
CommonUtil.emitEvent("friendListener", "onFriendApplicationRejected", s);
}
@Override
public void onFriendDeleted(String s) {
CommonUtil.emitEvent("friendListener", "onFriendDeleted", s);
}
@Override
public void onFriendInfoChanged(String s) {
CommonUtil.emitEvent("friendListener", "onFriendInfoChanged", s);
}
}

View File

@@ -0,0 +1,56 @@
package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
public class OnGroupListener implements open_im_sdk_callback.OnGroupListener {
@Override
public void onGroupApplicationAccepted(String s) {
CommonUtil.emitEvent("groupListener", "onGroupApplicationAccepted", s);
}
@Override
public void onGroupApplicationAdded(String s) {
CommonUtil.emitEvent("groupListener", "onGroupApplicationAdded", s);
}
@Override
public void onGroupApplicationDeleted(String s) {
CommonUtil.emitEvent("groupListener", "onGroupApplicationDeleted", s);
}
@Override
public void onGroupApplicationRejected(String s) {
CommonUtil.emitEvent("groupListener", "onGroupApplicationRejected", s);
}
@Override
public void onGroupInfoChanged(String s) {
CommonUtil.emitEvent("groupListener", "onGroupInfoChanged", s);
}
@Override
public void onGroupMemberAdded(String s) {
CommonUtil.emitEvent("groupListener", "onGroupMemberAdded", s);
}
@Override
public void onGroupMemberDeleted(String s) {
CommonUtil.emitEvent("groupListener", "onGroupMemberDeleted", s);
}
@Override
public void onGroupMemberInfoChanged(String s) {
CommonUtil.emitEvent("groupListener", "onGroupMemberInfoChanged", s);
}
@Override
public void onJoinedGroupAdded(String s) {
CommonUtil.emitEvent("groupListener", "onJoinedGroupAdded", s);
}
@Override
public void onJoinedGroupDeleted(String s) {
CommonUtil.emitEvent("groupListener", "onJoinedGroupDeleted", s);
}
}

View File

@@ -7,32 +7,34 @@ import java.util.Map;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.SendMsgCallBack; import open_im_sdk_callback.SendMsgCallBack;
public class MsgSendProgressListener implements SendMsgCallBack { public class OnMsgSendListener implements SendMsgCallBack {
final private MethodChannel.Result result; final private MethodChannel.Result result;
// final private MethodCall call; private Object clientMsgID;
final private Object clientMsgID;
public MsgSendProgressListener(MethodChannel.Result result, MethodCall call) { public OnMsgSendListener(MethodChannel.Result result, MethodCall call) {
this.result = result; this.result = result;
// this.call = call;
Map<String, Object> args = call.argument("message"); Map<String, Object> args = call.argument("message");
if (null != args) {
this.clientMsgID = args.get("clientMsgID"); this.clientMsgID = args.get("clientMsgID");
} }
}
@Override @Override
public void onError(long l, String s) { public void onError(int l, String s) {
CommonUtil.runMainThreadReturnError(result, l, s, null); CommonUtil.runMainThreadReturnError(result, l, s, null);
} }
@Override @Override
public void onProgress(long l) { public void onProgress(long l) {
if (null != clientMsgID) {
final Map<String, Object> values = new ArrayMap<>(); final Map<String, Object> values = new ArrayMap<>();
values.put("clientMsgID", clientMsgID); values.put("clientMsgID", clientMsgID);
values.put("progress", l); values.put("progress", l);
CommonUtil.emitEvent("msgSendProgressListener", "onProgress", values); CommonUtil.emitEvent("msgSendProgressListener", "onProgress", values);
} }
}
@Override @Override
public void onSuccess(String s) { public void onSuccess(String s) {

View File

@@ -0,0 +1,11 @@
package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
public class OnUserListener implements open_im_sdk_callback.OnUserListener {
@Override
public void onSelfInfoUpdated(String s) {
CommonUtil.emitEvent("userListener", "onSelfInfoUpdated", s);
}
}

View File

@@ -1,38 +0,0 @@
package io.openim.flutter_openim_sdk.listener;
import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.IMSDKListener;
public class SDKListener implements IMSDKListener {
@Override
public void onConnectFailed(long l, String s) {
CommonUtil.emitEvent("initSDKListener", "onConnectFailed", l, s, null);
}
@Override
public void onConnectSuccess() {
CommonUtil.emitEvent("initSDKListener", "onConnectSuccess", null);
}
@Override
public void onConnecting() {
CommonUtil.emitEvent("initSDKListener", "onConnecting", null);
}
@Override
public void onKickedOffline() {
CommonUtil.emitEvent("initSDKListener", "onKickedOffline", null);
}
@Override
public void onSelfInfoUpdated(String s) {
CommonUtil.emitEvent("initSDKListener", "onSelfInfoUpdated", s);
}
@Override
public void onUserTokenExpired() {
CommonUtil.emitEvent("initSDKListener", "onUserTokenExpired", null);
}
}

View File

@@ -2,68 +2,98 @@ package io.openim.flutter_openim_sdk.manager;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.BaseListener; import io.openim.flutter_openim_sdk.listener.OnBaseListener;
import io.openim.flutter_openim_sdk.listener.ConversationListener; import io.openim.flutter_openim_sdk.listener.OnConversationListener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
public class ConversationManager extends BaseManager { public class ConversationManager extends BaseManager {
public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) { public void setConversationListener(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setConversationListener(new ConversationListener()); Open_im_sdk.setConversationListener(new OnConversationListener());
} }
public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) { public void getAllConversationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getAllConversationList(new BaseListener(result)); Open_im_sdk.getAllConversationList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
}
public void getConversationListSplit(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getConversationListSplit(
new OnBaseListener(result),
value(methodCall, "operationID"),
int2long(methodCall, "offset"),
int2long(methodCall, "count")
);
} }
public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) { public void getOneConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getOneConversation( Open_im_sdk.getOneConversation(
value(methodCall, "sourceID"), new OnBaseListener(result),
value(methodCall, "operationID"),
int2long(methodCall, "sessionType"), int2long(methodCall, "sessionType"),
new BaseListener(result)); value(methodCall, "sourceID")
);
} }
public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) { public void getMultipleConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getMultipleConversation( Open_im_sdk.getMultipleConversation(
jsonValue(methodCall, "conversationIDList"), new OnBaseListener(result),
new BaseListener(result)); value(methodCall, "operationID"),
jsonValue(methodCall, "conversationIDList")
);
} }
public void deleteConversation(MethodCall methodCall, MethodChannel.Result result) { public void deleteConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.deleteConversation( Open_im_sdk.deleteConversation(
value(methodCall, "conversationID"), new OnBaseListener(result),
new BaseListener(result)); value(methodCall, "operationID"),
value(methodCall, "conversationID")
);
} }
public void setConversationDraft(MethodCall methodCall, MethodChannel.Result result) { public void setConversationDraft(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setConversationDraft( Open_im_sdk.setConversationDraft(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "conversationID"), value(methodCall, "conversationID"),
value(methodCall, "draftText"), value(methodCall, "draftText")
new BaseListener(result)); );
} }
public void pinConversation(MethodCall methodCall, MethodChannel.Result result) { public void pinConversation(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.pinConversation( Open_im_sdk.pinConversation(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "conversationID"), value(methodCall, "conversationID"),
value(methodCall, "isPinned"), value(methodCall, "isPinned")
new BaseListener(result)); );
} }
public void markSingleMessageHasRead(MethodCall methodCall, MethodChannel.Result result) { // public void markSingleMessageHasRead(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.markSingleMessageHasRead( // Open_im_sdk.markSingleMessageHasRead(
new BaseListener(result), // new OnBaseListener(result),
value(methodCall, "userID")); // value(methodCall, "operationID"),
} // value(methodCall, "userID")
// );
// }
public void markGroupMessageHasRead(MethodCall methodCall, MethodChannel.Result result) { public void markGroupMessageHasRead(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.markGroupMessageHasRead( Open_im_sdk.markGroupMessageHasRead(
new BaseListener(result), new OnBaseListener(result),
value(methodCall, "groupID")); value(methodCall, "operationID"),
value(methodCall, "groupID")
);
} }
public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) { public void getTotalUnreadMsgCount(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getTotalUnreadMsgCount(new BaseListener(result)); Open_im_sdk.getTotalUnreadMsgCount(
new OnBaseListener(result),
value(methodCall, "operationID")
);
} }
public void getConversationIDBySessionType(MethodCall methodCall, MethodChannel.Result result) { public void getConversationIDBySessionType(MethodCall methodCall, MethodChannel.Result result) {
@@ -71,4 +101,21 @@ public class ConversationManager extends BaseManager {
value(methodCall, "sourceID"), value(methodCall, "sourceID"),
int2long(methodCall, "sessionType"))); int2long(methodCall, "sessionType")));
} }
public void setConversationRecvMessageOpt(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setConversationRecvMessageOpt(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "conversationIDList"),
int2long(methodCall, "status")
);
}
public void getConversationRecvMessageOpt(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getConversationRecvMessageOpt(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "conversationIDList")
);
}
} }

View File

@@ -2,72 +2,115 @@ package io.openim.flutter_openim_sdk.manager;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.BaseListener; import io.openim.flutter_openim_sdk.listener.OnBaseListener;
import io.openim.flutter_openim_sdk.listener.FriendshipListener; import io.openim.flutter_openim_sdk.listener.OnFriendshipListener;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
public class FriendshipManager extends BaseManager { public class FriendshipManager extends BaseManager {
public void setFriendListener(MethodCall methodCall, MethodChannel.Result result) { public void setFriendListener(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setFriendListener(new FriendshipListener()); Open_im_sdk.setFriendListener(new OnFriendshipListener());
} }
public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) { public void getFriendsInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getFriendsInfo(new BaseListener(result), Open_im_sdk.getDesignatedFriendsInfo(
jsonValue(methodCall, "uidList")); new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "uidList")
);
} }
public void addFriend(MethodCall methodCall, MethodChannel.Result result) { public void addFriend(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.addFriend(new BaseListener(result), Open_im_sdk.addFriend(
jsonValue(methodCall)); new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall)
);
} }
public void getFriendApplicationList(MethodCall methodCall, MethodChannel.Result result) { public void getRecvFriendApplicationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getFriendApplicationList(new BaseListener(result)); Open_im_sdk.getRecvFriendApplicationList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
}
public void getSendFriendApplicationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getSendFriendApplicationList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
} }
public void getFriendList(MethodCall methodCall, MethodChannel.Result result) { public void getFriendList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getFriendList(new BaseListener(result)); Open_im_sdk.getFriendList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
} }
public void setFriendInfo(MethodCall methodCall, MethodChannel.Result result) { public void setFriendRemark(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setFriendInfo( Open_im_sdk.setFriendRemark(
jsonValue(methodCall), new BaseListener(result)); new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall)
);
} }
public void addToBlackList(MethodCall methodCall, MethodChannel.Result result) { public void addBlacklist(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.addToBlackList(new BaseListener(result), Open_im_sdk.addBlack(
jsonValue(methodCall, "uid")); new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "uid")
);
} }
public void getBlackList(MethodCall methodCall, MethodChannel.Result result) { public void getBlacklist(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getBlackList(new BaseListener(result)); Open_im_sdk.getBlackList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
} }
public void deleteFromBlackList(MethodCall methodCall, MethodChannel.Result result) { public void removeBlacklist(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.deleteFromBlackList(new BaseListener(result), Open_im_sdk.removeBlack(
jsonValue(methodCall, "uid")); new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "uid")
);
} }
public void checkFriend(MethodCall methodCall, MethodChannel.Result result) { public void checkFriend(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.checkFriend(new BaseListener(result), Open_im_sdk.checkFriend(
jsonValue(methodCall, "uidList")); new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "uidList")
);
} }
public void deleteFromFriendList(MethodCall methodCall, MethodChannel.Result result) { public void deleteFriend(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.deleteFromFriendList( Open_im_sdk.deleteFriend(
jsonValue(methodCall, "uid"), new BaseListener(result)); new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "uid")
);
} }
public void acceptFriendApplication(MethodCall methodCall, MethodChannel.Result result) { public void acceptFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.acceptFriendApplication(new BaseListener(result), Open_im_sdk.acceptFriendApplication(
jsonValue(methodCall, "uid")); new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall)
);
} }
public void refuseFriendApplication(MethodCall methodCall, MethodChannel.Result result) { public void refuseFriendApplication(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.refuseFriendApplication(new BaseListener(result), Open_im_sdk.refuseFriendApplication(
jsonValue(methodCall, "uid")); new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall)
);
} }
// public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) { // public void forceSyncFriendApplication(MethodCall methodCall, MethodChannel.Result result) {

View File

@@ -2,104 +2,149 @@ package io.openim.flutter_openim_sdk.manager;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.BaseListener; import io.openim.flutter_openim_sdk.listener.OnBaseListener;
import io.openim.flutter_openim_sdk.listener.GroupListener; import io.openim.flutter_openim_sdk.listener.OnGroupListener;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
public class GroupManager extends BaseManager { public class GroupManager extends BaseManager {
public void setGroupListener(MethodCall methodCall, MethodChannel.Result result) { public void setGroupListener(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setGroupListener(new GroupListener()); Open_im_sdk.setGroupListener(new OnGroupListener());
} }
public void inviteUserToGroup(MethodCall methodCall, MethodChannel.Result result) { public void inviteUserToGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.inviteUserToGroup( Open_im_sdk.inviteUserToGroup(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "gid"), value(methodCall, "gid"),
value(methodCall, "reason"), value(methodCall, "reason"),
jsonValue(methodCall, "uidList"), jsonValue(methodCall, "uidList")
new BaseListener(result)); );
} }
public void kickGroupMember(MethodCall methodCall, MethodChannel.Result result) { public void kickGroupMember(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.kickGroupMember( Open_im_sdk.kickGroupMember(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "gid"), value(methodCall, "gid"),
value(methodCall, "reason"), value(methodCall, "reason"),
jsonValue(methodCall, "uidList"), jsonValue(methodCall, "uidList")
new BaseListener(result)); );
} }
public void getGroupMembersInfo(MethodCall methodCall, MethodChannel.Result result) { public void getGroupMembersInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupMembersInfo( Open_im_sdk.getGroupMembersInfo(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "gid"), value(methodCall, "gid"),
jsonValue(methodCall, "uidList"), jsonValue(methodCall, "uidList")
new BaseListener(result)); );
} }
public void getGroupMemberList(MethodCall methodCall, MethodChannel.Result result) { public void getGroupMemberList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupMemberList( Open_im_sdk.getGroupMemberList(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "gid"), value(methodCall, "gid"),
value(methodCall, "filter"), value(methodCall, "filter"),
value(methodCall, "next"), value(methodCall, "offset"),
new BaseListener(result)); value(methodCall, "count")
);
} }
public void getJoinedGroupList(MethodCall methodCall, MethodChannel.Result result) { public void getJoinedGroupList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getJoinedGroupList(new BaseListener(result)); Open_im_sdk.getJoinedGroupList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
} }
public void createGroup(MethodCall methodCall, MethodChannel.Result result) { public void createGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.createGroup( Open_im_sdk.createGroup(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "gInfo"), jsonValue(methodCall, "gInfo"),
jsonValue(methodCall, "memberList"), jsonValue(methodCall, "memberList")
new BaseListener(result)); );
} }
public void setGroupInfo(MethodCall methodCall, MethodChannel.Result result) { public void setGroupInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setGroupInfo(jsonValue(methodCall, "gInfo"), new BaseListener(result)); Open_im_sdk.setGroupInfo(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "gid"),
jsonValue(methodCall, "gInfo")
);
} }
public void getGroupsInfo(MethodCall methodCall, MethodChannel.Result result) { public void getGroupsInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupsInfo(jsonValue(methodCall, "gidList"), new BaseListener(result)); Open_im_sdk.getGroupsInfo(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "gidList")
);
} }
public void joinGroup(MethodCall methodCall, MethodChannel.Result result) { public void joinGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.joinGroup( Open_im_sdk.joinGroup(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "gid"), value(methodCall, "gid"),
value(methodCall, "reason"), value(methodCall, "reason")
new BaseListener(result)); );
} }
public void quitGroup(MethodCall methodCall, MethodChannel.Result result) { public void quitGroup(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.quitGroup( Open_im_sdk.quitGroup(
value(methodCall, "gid"), new OnBaseListener(result),
new BaseListener(result)); value(methodCall, "operationID"),
value(methodCall, "gid")
);
} }
public void transferGroupOwner(MethodCall methodCall, MethodChannel.Result result) { public void transferGroupOwner(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.transferGroupOwner( Open_im_sdk.transferGroupOwner(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "gid"), value(methodCall, "gid"),
value(methodCall, "uid"), value(methodCall, "uid")
new BaseListener(result)); );
} }
public void getGroupApplicationList(MethodCall methodCall, MethodChannel.Result result) { public void getRecvGroupApplicationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getGroupApplicationList(new BaseListener(result)); Open_im_sdk.getRecvGroupApplicationList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
}
public void getSendGroupApplicationList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getSendGroupApplicationList(
new OnBaseListener(result),
value(methodCall, "operationID")
);
} }
public void acceptGroupApplication(MethodCall methodCall, MethodChannel.Result result) { public void acceptGroupApplication(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.acceptGroupApplication( Open_im_sdk.acceptGroupApplication(
jsonValue(methodCall, "application"), new OnBaseListener(result),
value(methodCall, "reason"), value(methodCall, "operationID"),
new BaseListener(result)); value(methodCall, "gid"),
value(methodCall, "uid"),
value(methodCall, "handleMsg")
);
} }
public void refuseGroupApplication(MethodCall methodCall, MethodChannel.Result result) { public void refuseGroupApplication(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.refuseGroupApplication( Open_im_sdk.refuseGroupApplication(
jsonValue(methodCall, "application"), new OnBaseListener(result),
value(methodCall, "reason"), value(methodCall, "operationID"),
new BaseListener(result)); value(methodCall, "gid"),
value(methodCall, "uid"),
value(methodCall, "handleMsg")
);
} }

View File

@@ -2,8 +2,8 @@ package io.openim.flutter_openim_sdk.manager;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.BaseListener; import io.openim.flutter_openim_sdk.listener.OnBaseListener;
import io.openim.flutter_openim_sdk.listener.SDKListener; import io.openim.flutter_openim_sdk.listener.OnConnListener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
@@ -11,18 +11,26 @@ public class IMManager extends BaseManager {
public void initSDK(MethodCall methodCall, MethodChannel.Result result) { public void initSDK(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.initSDK( CommonUtil.runMainThreadReturn(result, Open_im_sdk.initSDK(
jsonValue(methodCall), new SDKListener())); new OnConnListener(),
// CommonUtil.runMainThreadReturn(result, null); value(methodCall, "operationID"),
jsonValue(methodCall))
);
} }
public void login(MethodCall methodCall, MethodChannel.Result result) { public void login(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.login( Open_im_sdk.login(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "uid"), value(methodCall, "uid"),
value(methodCall, "token"), new BaseListener(result)); value(methodCall, "token")
);
} }
public void logout(MethodCall methodCall, MethodChannel.Result result) { public void logout(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.logout(new BaseListener(result)); Open_im_sdk.logout(
new OnBaseListener(result),
value(methodCall, "operationID")
);
} }
public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) { public void getLoginStatus(MethodCall methodCall, MethodChannel.Result result) {
@@ -33,25 +41,25 @@ public class IMManager extends BaseManager {
// CommonUtil.runMainThreadReturn(result, Open_im_sdk.getLoginUid()); // CommonUtil.runMainThreadReturn(result, Open_im_sdk.getLoginUid());
// } // }
public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) { // public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getUsersInfo( // Open_im_sdk.getUsersInfo(
jsonValue(methodCall, "uidList"), new BaseListener(result)); // jsonValue(methodCall, "uidList"), new BaseListener(result));
} // }
public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) { // public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setSelfInfo( // Open_im_sdk.setSelfInfo(
jsonValue(methodCall), new BaseListener(result)); // jsonValue(methodCall), new BaseListener(result));
} // }
public void forceSyncLoginUerInfo(MethodCall methodCall, MethodChannel.Result result) { // public void forceSyncLoginUerInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncLoginUerInfo(); // Open_im_sdk.forceSyncLoginUerInfo();
} // }
// public void forceReConn(MethodCall methodCall, MethodChannel.Result result) { // public void forceReConn(MethodCall methodCall, MethodChannel.Result result) {
// Open_im_sdk.forceReConn(); // Open_im_sdk.forceReConn();
// } // }
public void setSdkLog(MethodCall methodCall, MethodChannel.Result result) { // public void setSdkLog(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setSdkLog(value(methodCall, "sdkLog")); // Open_im_sdk.setSdkLog(value(methodCall, "sdkLog"));
} // }
} }

View File

@@ -1,24 +1,25 @@
package io.openim.flutter_openim_sdk.manager; package io.openim.flutter_openim_sdk.manager;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.AdvancedMsgListener; import io.openim.flutter_openim_sdk.listener.OnAdvancedMsgListener;
import io.openim.flutter_openim_sdk.listener.BaseListener; import io.openim.flutter_openim_sdk.listener.OnBaseListener;
import io.openim.flutter_openim_sdk.listener.MsgSendProgressListener; import io.openim.flutter_openim_sdk.listener.OnMsgSendListener;
import io.openim.flutter_openim_sdk.util.CommonUtil; import io.openim.flutter_openim_sdk.util.CommonUtil;
import open_im_sdk.OnAdvancedMsgListener;
import open_im_sdk.Open_im_sdk; import open_im_sdk.Open_im_sdk;
public class MessageManager extends BaseManager { public class MessageManager extends BaseManager {
private final static String KEY_ID = "id"; private final static String KEY_ID = "id";
// private final static Map<String, OnAdvancedMsgListener> listeners = new HashMap<>(); // private final static Map<String, OnAdvancedMsgListener> listeners = new HashMap<>();
private static boolean initializedListener = false; /* private static boolean initializedListener = false;
private final static Map<String, AdvancedMsgListener> listeners = new ConcurrentHashMap<>(); private final static Map<String, AdvancedMsgListener> listeners = new ConcurrentHashMap<>();
protected void clearListeners() {
initializedListener = false;
listeners.clear();
}
private final static OnAdvancedMsgListener sdkMsgListener = new OnAdvancedMsgListener() { private final static OnAdvancedMsgListener sdkMsgListener = new OnAdvancedMsgListener() {
@Override @Override
public void onRecvC2CReadReceipt(String s) { public void onRecvC2CReadReceipt(String s) {
@@ -44,6 +45,7 @@ public class MessageManager extends BaseManager {
public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) {
String key = methodCall.argument(KEY_ID); String key = methodCall.argument(KEY_ID);
Open_im_sdk.addAdvancedMsgListener(new AdvancedMsgListener(key));
listeners.put(key, new AdvancedMsgListener(key)); listeners.put(key, new AdvancedMsgListener(key));
if (!initializedListener) { if (!initializedListener) {
initializedListener = true; initializedListener = true;
@@ -56,9 +58,9 @@ public class MessageManager extends BaseManager {
listeners.remove(key); listeners.remove(key);
if (listeners.isEmpty()) { if (listeners.isEmpty()) {
initializedListener = false; initializedListener = false;
// Open_im_sdk.removeAdvancedMsgListener(sdkMsgListener); Open_im_sdk.removeAdvancedMsgListener(sdkMsgListener);
}
} }
}*/
/* /*
public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) { public void addAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) {
@@ -77,63 +79,93 @@ public class MessageManager extends BaseManager {
} }
*/ */
public void setAdvancedMsgListener(MethodCall methodCall, MethodChannel.Result result) {
String key = methodCall.argument(KEY_ID);
Open_im_sdk.setAdvancedMsgListener(new OnAdvancedMsgListener(key));
}
public void sendMessage(MethodCall methodCall, MethodChannel.Result result) { public void sendMessage(MethodCall methodCall, MethodChannel.Result result) {
MsgSendProgressListener listener = new MsgSendProgressListener(result, methodCall); Open_im_sdk.sendMessage(
Open_im_sdk.sendMessage(listener, new OnMsgSendListener(result, methodCall),
value(methodCall, "operationID"),
jsonValue(methodCall, "message"), jsonValue(methodCall, "message"),
value(methodCall, "receiver"), value(methodCall, "userID"),
value(methodCall, "groupID"), value(methodCall, "groupID"),
value(methodCall, "onlineUserOnly")); jsonValue(methodCall, "offlinePushInfo")
);
} }
public void getHistoryMessageList(MethodCall methodCall, MethodChannel.Result result) { public void getHistoryMessageList(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getHistoryMessageList(new BaseListener(result), jsonValue(methodCall)); Open_im_sdk.getHistoryMessageList(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall)
);
} }
public void revokeMessage(MethodCall methodCall, MethodChannel.Result result) { public void revokeMessage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.revokeMessage(new BaseListener(result), jsonValue(methodCall)); Open_im_sdk.revokeMessage(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall)
);
} }
public void deleteMessageFromLocalStorage(MethodCall methodCall, MethodChannel.Result result) { public void deleteMessageFromLocalStorage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.deleteMessageFromLocalStorage(new BaseListener(result), jsonValue(methodCall)); Open_im_sdk.deleteMessageFromLocalStorage(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall)
);
} }
public void deleteMessages(MethodCall methodCall, MethodChannel.Result result) { // public void deleteMessages(MethodCall methodCall, MethodChannel.Result result) {
// Open_im_sdk.deleteMessages(new BaseListener(result), CommonUtil.getSDKJsonParam(methodCall)); // Open_im_sdk.deleteMessages(new OnBaseListener(result), CommonUtil.getSDKJsonParam(methodCall));
} // }
public void insertSingleMessageToLocalStorage(MethodCall methodCall, MethodChannel.Result result) { public void insertSingleMessageToLocalStorage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.insertSingleMessageToLocalStorage(new BaseListener(result), Open_im_sdk.insertSingleMessageToLocalStorage(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "message"), jsonValue(methodCall, "message"),
value(methodCall, "userID"), value(methodCall, "receiverID"),
value(methodCall, "sender")); value(methodCall, "senderID")
);
} }
public void findMessages(MethodCall methodCall, MethodChannel.Result result) { // public void findMessages(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.findMessages(new BaseListener(result), jsonValue(methodCall, "messageIDList")); // Open_im_sdk.findMessages(new OnBaseListener(result), jsonValue(methodCall, "messageIDList"));
} // }
public void markC2CMessageAsRead(MethodCall methodCall, MethodChannel.Result result) { public void markC2CMessageAsRead(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.markC2CMessageAsRead(new BaseListener(result), Open_im_sdk.markC2CMessageAsRead(
new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "userID"), value(methodCall, "userID"),
jsonValue(methodCall, "messageIDList")); jsonValue(methodCall, "messageIDList")
);
} }
public void typingStatusUpdate(MethodCall methodCall, MethodChannel.Result result) { public void typingStatusUpdate(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.typingStatusUpdate(value(methodCall, "userID"), Open_im_sdk.typingStatusUpdate(
value(methodCall, "typing")); new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "userID"),
value(methodCall, "msgTip")
);
} }
public void createTextMessage(MethodCall methodCall, MethodChannel.Result result) { public void createTextMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createTextMessage( Open_im_sdk.createTextMessage(
value(methodCall, "operationID"),
value(methodCall, "text"))); value(methodCall, "text")));
} }
public void createTextAtMessage(MethodCall methodCall, MethodChannel.Result result) { public void createTextAtMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createTextAtMessage( Open_im_sdk.createTextAtMessage(
value(methodCall, "operationID"),
value(methodCall, "text"), value(methodCall, "text"),
jsonValue(methodCall, "atUserList"))); jsonValue(methodCall, "atUserList")));
} }
@@ -141,17 +173,20 @@ public class MessageManager extends BaseManager {
public void createImageMessage(MethodCall methodCall, MethodChannel.Result result) { public void createImageMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createImageMessage( Open_im_sdk.createImageMessage(
value(methodCall, "operationID"),
value(methodCall, "imagePath"))); value(methodCall, "imagePath")));
} }
public void createImageMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) { public void createImageMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createImageMessageFromFullPath( Open_im_sdk.createImageMessageFromFullPath(
value(methodCall, "operationID"),
value(methodCall, "imagePath"))); value(methodCall, "imagePath")));
} }
public void createSoundMessage(MethodCall methodCall, MethodChannel.Result result) { public void createSoundMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createSoundMessage( Open_im_sdk.createSoundMessage(
value(methodCall, "operationID"),
value(methodCall, "soundPath"), value(methodCall, "soundPath"),
int2long(methodCall, "duration"))); int2long(methodCall, "duration")));
} }
@@ -159,6 +194,7 @@ public class MessageManager extends BaseManager {
public void createSoundMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) { public void createSoundMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createSoundMessageFromFullPath( Open_im_sdk.createSoundMessageFromFullPath(
value(methodCall, "operationID"),
value(methodCall, "soundPath"), value(methodCall, "soundPath"),
int2long(methodCall, "duration"))); int2long(methodCall, "duration")));
} }
@@ -166,6 +202,7 @@ public class MessageManager extends BaseManager {
public void createVideoMessage(MethodCall methodCall, MethodChannel.Result result) { public void createVideoMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createVideoMessage( Open_im_sdk.createVideoMessage(
value(methodCall, "operationID"),
value(methodCall, "videoPath"), value(methodCall, "videoPath"),
value(methodCall, "videoType"), value(methodCall, "videoType"),
int2long(methodCall, "duration"), int2long(methodCall, "duration"),
@@ -175,6 +212,7 @@ public class MessageManager extends BaseManager {
public void createVideoMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) { public void createVideoMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createVideoMessageFromFullPath( Open_im_sdk.createVideoMessageFromFullPath(
value(methodCall, "operationID"),
value(methodCall, "videoPath"), value(methodCall, "videoPath"),
value(methodCall, "videoType"), value(methodCall, "videoType"),
int2long(methodCall, "duration"), int2long(methodCall, "duration"),
@@ -184,6 +222,7 @@ public class MessageManager extends BaseManager {
public void createFileMessage(MethodCall methodCall, MethodChannel.Result result) { public void createFileMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createFileMessage( Open_im_sdk.createFileMessage(
value(methodCall, "operationID"),
value(methodCall, "filePath"), value(methodCall, "filePath"),
value(methodCall, "fileName"))); value(methodCall, "fileName")));
} }
@@ -191,6 +230,7 @@ public class MessageManager extends BaseManager {
public void createFileMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) { public void createFileMessageFromFullPath(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createFileMessageFromFullPath( Open_im_sdk.createFileMessageFromFullPath(
value(methodCall, "operationID"),
value(methodCall, "filePath"), value(methodCall, "filePath"),
value(methodCall, "fileName"))); value(methodCall, "fileName")));
} }
@@ -198,6 +238,7 @@ public class MessageManager extends BaseManager {
public void createMergerMessage(MethodCall methodCall, MethodChannel.Result result) { public void createMergerMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createMergerMessage( Open_im_sdk.createMergerMessage(
value(methodCall, "operationID"),
jsonValue(methodCall, "messageList"), jsonValue(methodCall, "messageList"),
value(methodCall, "title"), value(methodCall, "title"),
jsonValue(methodCall, "summaryList"))); jsonValue(methodCall, "summaryList")));
@@ -207,11 +248,13 @@ public class MessageManager extends BaseManager {
public void createForwardMessage(MethodCall methodCall, MethodChannel.Result result) { public void createForwardMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, CommonUtil.runMainThreadReturn(result,
Open_im_sdk.createForwardMessage( Open_im_sdk.createForwardMessage(
value(methodCall, "operationID"),
jsonValue(methodCall, "message"))); jsonValue(methodCall, "message")));
} }
public void createLocationMessage(MethodCall methodCall, MethodChannel.Result result) { public void createLocationMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createLocationMessage( CommonUtil.runMainThreadReturn(result, Open_im_sdk.createLocationMessage(
value(methodCall, "operationID"),
value(methodCall, "description"), value(methodCall, "description"),
value(methodCall, "longitude"), value(methodCall, "longitude"),
value(methodCall, "latitude") value(methodCall, "latitude")
@@ -220,6 +263,7 @@ public class MessageManager extends BaseManager {
public void createCustomMessage(MethodCall methodCall, MethodChannel.Result result) { public void createCustomMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createCustomMessage( CommonUtil.runMainThreadReturn(result, Open_im_sdk.createCustomMessage(
value(methodCall, "operationID"),
value(methodCall, "data"), value(methodCall, "data"),
value(methodCall, "extension"), value(methodCall, "extension"),
value(methodCall, "description") value(methodCall, "description")
@@ -228,6 +272,7 @@ public class MessageManager extends BaseManager {
public void createQuoteMessage(MethodCall methodCall, MethodChannel.Result result) { public void createQuoteMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createQuoteMessage( CommonUtil.runMainThreadReturn(result, Open_im_sdk.createQuoteMessage(
value(methodCall, "operationID"),
value(methodCall, "quoteText"), value(methodCall, "quoteText"),
jsonValue(methodCall, "quoteMessage") jsonValue(methodCall, "quoteMessage")
)); ));
@@ -235,21 +280,28 @@ public class MessageManager extends BaseManager {
public void createCardMessage(MethodCall methodCall, MethodChannel.Result result) { public void createCardMessage(MethodCall methodCall, MethodChannel.Result result) {
CommonUtil.runMainThreadReturn(result, Open_im_sdk.createCardMessage( CommonUtil.runMainThreadReturn(result, Open_im_sdk.createCardMessage(
value(methodCall, "operationID"),
jsonValue(methodCall, "cardMessage") jsonValue(methodCall, "cardMessage")
)); ));
} }
public void forceSyncMsg(MethodCall methodCall, MethodChannel.Result result) { // public void forceSyncMsg(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.forceSyncMsg(); // Open_im_sdk.forceSyncMsg();
} // }
public void clearC2CHistoryMessage(MethodCall methodCall, MethodChannel.Result result) { public void clearC2CHistoryMessage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.clearC2CHistoryMessage(new BaseListener(result), Open_im_sdk.clearC2CHistoryMessage(
value(methodCall, "userID")); new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "userID")
);
} }
public void clearGroupHistoryMessage(MethodCall methodCall, MethodChannel.Result result) { public void clearGroupHistoryMessage(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.clearGroupHistoryMessage(new BaseListener(result), Open_im_sdk.clearGroupHistoryMessage(
value(methodCall, "groupID")); new OnBaseListener(result),
value(methodCall, "operationID"),
value(methodCall, "groupID")
);
} }
} }

View File

@@ -0,0 +1,35 @@
package io.openim.flutter_openim_sdk.manager;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.openim.flutter_openim_sdk.listener.OnBaseListener;
import io.openim.flutter_openim_sdk.listener.OnUserListener;
import open_im_sdk.Open_im_sdk;
public class UserManager extends BaseManager {
public void setUserListener(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setUserListener(new OnUserListener());
}
public void getUsersInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getUsersInfo(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall, "uidList"));
}
public void setSelfInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.setSelfInfo(
new OnBaseListener(result),
value(methodCall, "operationID"),
jsonValue(methodCall));
}
public void getSelfUserInfo(MethodCall methodCall, MethodChannel.Result result) {
Open_im_sdk.getSelfUserInfo(
new OnBaseListener(result),
value(methodCall, "operationID")
);
}
}

View File

@@ -32,7 +32,7 @@ public class CommonUtil {
runMainThreadReturnError(result, String.valueOf(errorCode), errorMessage, errorDetails); runMainThreadReturnError(result, String.valueOf(errorCode), errorMessage, errorDetails);
} }
public synchronized static <T> void emitEvent(String method, String type, Long errCode, String errMsg, T data) { public synchronized static <T> void emitEvent(String method, String type, Object errCode, String errMsg, T data) {
runMainThread(() -> { runMainThread(() -> {
Map<String, Object> res = new ArrayMap<>(); Map<String, Object> res = new ArrayMap<>();
if (null != type) { if (null != type) {

View File

@@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = { 97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1020; LastUpgradeCheck = 1300;
ORGANIZATIONNAME = ""; ORGANIZATIONNAME = "";
TargetAttributes = { TargetAttributes = {
97C146ED1CF9000F007C117D = { 97C146ED1CF9000F007C117D = {

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1020" LastUpgradeVersion = "1300"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"

View File

@@ -1,4 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
@@ -15,7 +14,6 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
@override @override
void initState() { void initState() {
_initSDK();
super.initState(); super.initState();
} }
@@ -28,81 +26,526 @@ class _MyAppState extends State<MyApp> {
), ),
body: Column( body: Column(
children: [ children: [
TextButton(onPressed: _login, child: Text('login')), TextButton(onPressed: () {}, child: Text('login')),
], ],
), ),
), ),
); );
} }
void _login() { void initSDK() {
if (OpenIM.iMManager.isInitialized)
OpenIM.iMManager.login(uid: '', token: '');
}
void _initSDK() async {
// Initialize SDK
OpenIM.iMManager OpenIM.iMManager
..initSDK( .initSDK(
platform: Platform.isAndroid ? IMPlatform.android : IMPlatform.ios, // "当前平台参照IMPlatform类",
ipApi: '', platform: 0,
ipWs: '', // SDK的API接口地址。如http:xxx:10000
dbPath: '', apiAddr: "",
listener: OnInitSDKListener( // SDK的web socket地址。如 ws:xxx:17778
onConnecting: () {}, wsAddr: "",
onConnectFailed: (code, error) {}, // 数据存储路径。如var apath =(await getApplicationDocumentsDirectory()).path
onConnectSuccess: () {}, dataDir: "",
onKickedOffline: () {}, listener: OnConnectListener(
onUserSigExpired: () {}, onConnectSuccess: () {
onSelfInfoUpdated: (user) {}, // 已经成功连接到服务器
},
onConnecting: () {
// 正在连接到服务器,适合在 UI 上展示“正在连接”状态。
},
onConnectFailed: (code, errorMsg) {
// 连接服务器失败,可以提示用户当前网络连接不可用
},
onUserSigExpired: () {
// 登录票据已经过期,请使用新签发的 UserSig 进行登录。
},
onKickedOffline: () {
// 当前用户被踢下线,此时可以 UI 提示用户“您已经在其他端登录了当前账号,是否重新登录?”
},
), ),
) )
.then((value) {
if (value == true) {
// 初始化成功
}
});
}
// Add message listener (remove when not in use) void setLisenter() {
..messageManager.addAdvancedMsgListener(OnAdvancedMsgListener( OpenIM.iMManager
onRecvMessageRevoked: (msgId) {}, ..userManager.setUserListener(OnUserListener(
onRecvC2CReadReceipt: (list) {}, onSelfInfoUpdated: (userInfo) {
onRecvNewMessage: (msg) {}, // 当前登录用户资料变更回调
},
))
..messageManager.setAdvancedMsgListener(OnAdvancedMsgListener(
onRecvNewMessage: (message) {
// 收到新消息,界面添加新消息
},
onRecvMessageRevoked: (messageID) {
// 消息成功撤回,从界面移除消息
},
onRecvC2CReadReceipt: (list) {
// 消息被阅读回执,将消息标记为已读
},
)) ))
// Set up message sending progress listener
..messageManager.setMsgSendProgressListener(OnMsgSendProgressListener( ..messageManager.setMsgSendProgressListener(OnMsgSendProgressListener(
onProgress: (msgId, progress) {}, onProgress: (messageID, progress) {
// 消息发送进度回调
},
)) ))
// Set up friend relationship listener
..friendshipManager.setFriendshipListener(OnFriendshipListener( ..friendshipManager.setFriendshipListener(OnFriendshipListener(
onBlackListAdd: (u) {}, onFriendApplicationRejected: (applicationInfo) {
onBlackListDeleted: (u) {}, // 发出或收到的好友申请被拒绝
onFriendApplicationListAccept: (u) {}, },
onFriendApplicationListAdded: (u) {}, onFriendApplicationDeleted: (applicationInfo) {
onFriendApplicationListDeleted: (u) {}, // 发出或收到的好友申请被删除
onFriendApplicationListReject: (u) {}, },
onFriendInfoChanged: (u) {}, onFriendApplicationAdded: (applicationInfo) {
onFriendListAdded: (u) {}, // 发出或收到的好友申请被添加
onFriendListDeleted: (u) {}, },
onFriendApplicationAccepted: (applicationInfo) {
// 发出或收到的好友申请已同意
},
onFriendAdded: (frinedInfo) {
// 好友被添加
},
onFriendDeleted: (frinedInfo) {
// 好友被删除
},
onFriendInfoChanged: (frinedInfo) {
// 朋友的资料发生变化
},
onBlacklistDeleted: (blackInfo) {
// 从黑名单删除
},
onBlacklistAdded: (blackInfo) {
// 拉入黑名单
},
)) ))
// Set up conversation listener
..conversationManager.setConversationListener(OnConversationListener( ..conversationManager.setConversationListener(OnConversationListener(
onConversationChanged: (list) {}, onNewConversation: (list) {
onNewConversation: (list) {}, // 新增会话
onTotalUnreadMessageCountChanged: (count) {}, },
onSyncServerFailed: () {}, onConversationChanged: (list) {
onSyncServerFinish: () {}, // 已添加的会话发送改变
onSyncServerStart: () {}, },
onTotalUnreadMessageCountChanged: (count) {
// 未读消息数发送变化
},
)) ))
// Set up group listener
..groupManager.setGroupListener(OnGroupListener( ..groupManager.setGroupListener(OnGroupListener(
onApplicationProcessed: (groupId, opUser, agreeOrReject, opReason) {}, onGroupMemberInfoChanged: (memberInfo) {
onGroupCreated: (groupId) {}, // 组成员信息发生变化
onGroupInfoChanged: (groupId, info) {}, },
onMemberEnter: (groupId, list) {}, onGroupMemberDeleted: (memberInfo) {
onMemberInvited: (groupId, opUser, list) {}, // 组成员退出
onMemberKicked: (groupId, opUser, list) {}, },
onMemberLeave: (groupId, info) {}, onGroupMemberAdded: (memberInfo) {
onReceiveJoinApplication: (groupId, info, opReason) {}, // 组成员进入
},
onGroupApplicationRejected: (applicationInfo) {
// 发出或收到的组申请被拒绝
},
onGroupApplicationDeleted: (applicationInfo) {
// 发出或收到的组申请被删除
},
onGroupApplicationAdded: (applicationInfo) {
// 发出或收到的组申请有新增
},
onGroupApplicationAccepted: (applicationInfo) {
// 发出或收到的组申请被接受
},
onJoinedGroupDeleted: (groupInfo) {
// 退出群:退出者收到;踢出群:被踢者收到
},
onJoinedGroupAdded: (groupInfo) {
// 创建群: 初始成员收到;邀请进群:被邀请者收到
},
onGroupInfoChanged: (groupInfo) {
// 组资料变更
},
)); ));
} }
void login() {
OpenIM.iMManager
.login(
uid: "", // uid来自于自身业务服务器
token: "", // token需要业务服务器根据secret向OpenIM服务端交换获取
)
.then((value) {
// 返回当前登录用户的资料
});
}
void imMager() {
OpenIM.iMManager.logout().then((_) {
// 退出成功
});
OpenIM.iMManager.getLoginUserInfo().then((userInfo) {
// 当前登录用户的信息
});
OpenIM.iMManager.getLoginUserID().then((userID) {
// 当前登录用户的ID
});
}
void userManager() {
OpenIM.iMManager.userManager.getUsersInfo(
uidList: [], // 用户ID集合
).then((userInfoList) {
// 用户信息列表
});
OpenIM.iMManager.userManager.getSelfUserInfo().then((userInfo) {
// 返回当前登录用户的资料
});
OpenIM.iMManager.userManager
.setSelfInfo(
nickname: '',
// 昵称
faceURL: '',
// 头像
gender: 0,
// 性别: 男1女0
phoneNumber: '',
// 手机号
email: '',
//邮箱
birth: 0,
//生日
ex: '', // 其他信息
)
.then((_) {});
}
void conversationManager() {
OpenIM.iMManager.conversationManager.getAllConversationList().then((list) {
// List<ConversationInfo> 会话列表
});
OpenIM.iMManager.conversationManager.getConversationListSplit(
offset: 0, // 偏移量第1页offet0count20第2页offset20
count: 0, // 每页数量
);
OpenIM.iMManager.conversationManager.getOneConversation(
sourceID: "", // 如果是单聊值传userID如果是群聊groupID
sessionType: 1, // 如果是单聊值传1如果是群聊值传2
);
OpenIM.iMManager.conversationManager.getMultipleConversation(
conversationIDList: [], // 会话ID集合
).then((list) {
// 返回与id匹配的会话列表
});
OpenIM.iMManager.conversationManager
.deleteConversation(
conversationID: "", // 会话id
)
.then((_) => null)
.catchError((_) {});
OpenIM.iMManager.conversationManager.setConversationDraft(
conversationID: "", // 会话id
draftText: "", // 草稿
);
OpenIM.iMManager.conversationManager.pinConversation(
conversationID: "", // 会话id
isPinned: true, // true置顶false取消置顶
);
OpenIM.iMManager.conversationManager.markGroupMessageHasRead(
groupID: "", // 组id
);
OpenIM.iMManager.conversationManager.getTotalUnreadMsgCount();
OpenIM.iMManager.conversationManager.getConversationIDBySessionType(
sourceID: "", // 如果是单聊值传userID如果是群聊groupID
sessionType: 1, // 如果是单聊值传1如果是群聊值传2
);
OpenIM.iMManager.conversationManager.setConversationRecvMessageOpt(
conversationIDList: [], // 会话id列表
status: 1, // 1不接受消息2接受在线消息不接受离线消息0正常
);
OpenIM.iMManager.conversationManager.getConversationRecvMessageOpt(
conversationIDList: [], // 会话id列表
);
OpenIM.iMManager.conversationManager.simpleSort([]);
}
void friendManager() {
OpenIM.iMManager.friendshipManager.getFriendsInfo(
uidList: [], // userId列表
).then((list) {
// List<UserInfo>
});
OpenIM.iMManager.friendshipManager.addFriend(
uid: "", // 用户id
reason: '', // 发起好友申请的描述信息
);
OpenIM.iMManager.friendshipManager
.getRecvFriendApplicationList()
.then((value) {
// List<FriendApplicationInfo> 申请列表
});
OpenIM.iMManager.friendshipManager
.getSendFriendApplicationList()
.then((list) {
// List<FriendApplicationInfo> 申请列表
});
OpenIM.iMManager.friendshipManager.getFriendList().then((list) {
// List<UserInfo> 好友信息列表
});
OpenIM.iMManager.friendshipManager.setFriendRemark(
uid: '', // 好友userID
remark: '', // 备注名
);
OpenIM.iMManager.friendshipManager.addBlacklist(
uid: "", // 好友userID
);
OpenIM.iMManager.friendshipManager.getBlacklist().then((list) {
// List<UserInfo>
});
OpenIM.iMManager.friendshipManager.removeBlacklist(
uid: "", // userID
);
OpenIM.iMManager.friendshipManager.checkFriend(
uidList: [], // userID 列表
).then((value) {
// List<FriendshipInfo>
});
OpenIM.iMManager.friendshipManager.deleteFriend(
uid: '', // userID
);
OpenIM.iMManager.friendshipManager.acceptFriendApplication(
uid: "", // userID
handleMsg: '', // 备注信息
);
OpenIM.iMManager.friendshipManager.refuseFriendApplication(
uid: "", // userID
handleMsg: '', // 备注信息
);
}
void groupManager() {
OpenIM.iMManager.groupManager
.inviteUserToGroup(
groupId: '', // 组ID
uidList: [], // 成员 userID 列表
reason: '', // 备注信息
)
.then((list) {
// List<GroupInviteResult>
});
OpenIM.iMManager.groupManager.kickGroupMember(
groupId: '', // 组ID
uidList: [], // userID 列表
reason: '', // 备注信息
);
OpenIM.iMManager.groupManager.getGroupMembersInfo(
groupId: '', // 组ID
uidList: [], // 成员 userID 列表
).then((list) {
// List<GroupMembersInfo>
});
OpenIM.iMManager.groupManager
.getGroupMemberList(
groupId: '', // 组ID
filter: 0, // 1普通成员, 2群主3管理员
offset: 0, // 偏移量每次开始的index值
count: 0, // 每次拉取的数量
)
.then((list) {
// List<GroupMembersInfo>
});
OpenIM.iMManager.groupManager.getJoinedGroupList().then((list) {
// List<GroupInfo>
});
OpenIM.iMManager.groupManager
.isJoinedGroup(
gid: '', // 组ID
)
.then((joned) {
// true已加入false未加入
});
OpenIM.iMManager.groupManager.createGroup(
groupName: '',
// 组名
faceUrl: '',
// 头像
notification: '',
// 群公告
introduction: '',
// 群简介
groupType: 0,
// 类型
ex: '',
// 扩展信息
list: [], // 成员角色集合 List<GroupMemberRole>
).then((groupInfo) {
// 返回组信息 GroupInfo
});
OpenIM.iMManager.groupManager.setGroupInfo(
groupID: '',
groupName: '',
// 组名
faceUrl: '',
// 头像
notification: '',
// 群公告
introduction: '',
// 群简介
ex: '', // 扩展信息
);
OpenIM.iMManager.groupManager.getGroupsInfo(
gidList: [], // 组id集合
).then((list) {
// List<GroupInfo>
});
OpenIM.iMManager.groupManager.joinGroup(
gid: '', // 组id
reason: '', // 入群备注信息
);
OpenIM.iMManager.groupManager.quitGroup(
gid: '', // 组id
);
OpenIM.iMManager.groupManager.transferGroupOwner(
gid: '', // 组ID
uid: '', // 新 owner userID
);
OpenIM.iMManager.groupManager.getRecvGroupApplicationList().then((list) {
// List<GroupApplicationInfo>
});
OpenIM.iMManager.groupManager.getSendGroupApplicationList().then((list) {
// List<GroupApplicationInfo>
});
OpenIM.iMManager.groupManager.acceptGroupApplication(
gid: '', // 组ID
uid: '', // 申请人userID
handleMsg: '', // 备注信息
);
OpenIM.iMManager.groupManager.refuseGroupApplication(
gid: '', // 组ID
uid: '', // 申请人userID
handleMsg: '', // 备注信息
);
}
void messageManager() {
OpenIM.iMManager.messageManager.sendMessage(
message: Message(), // 消息体
userID: '', // 接受消息的userID
groupID: '', // 接受消息的群ID
offlinePushInfo: OfflinePushInfo(), // 离线推送消息备注
);
OpenIM.iMManager.messageManager
.getHistoryMessageList(
userID: '', // 单聊对象的userID
groupID: '', // 群聊的组id
startMsg: null, // 消息体
count: 0, // 每次拉取的数量
)
.then((list) {
// List<Message>
});
OpenIM.iMManager.messageManager.revokeMessage(
message: Message(), // 消息体
);
OpenIM.iMManager.messageManager.deleteMessageFromLocalStorage(
message: Message(), // 消息体
);
OpenIM.iMManager.messageManager.insertSingleMessageToLocalStorage(
receiverID: '', // 接收者userID
senderID: '', // 发送者userID
message: Message(), // 消息体
);
OpenIM.iMManager.messageManager.markC2CMessageAsRead(
userID: '', // 接收者 userID
messageIDList: [], // 已读的消息id列表
);
OpenIM.iMManager.messageManager.typingStatusUpdate(
userID: '', // 接收者 userID
msgTip: '', // 自定义提示内容
);
OpenIM.iMManager.messageManager.createTextMessage(
text: '',
);
OpenIM.iMManager.messageManager.createTextAtMessage(
text: '', // 发送的内容
atUidList: [], // 被@到的userID集合
);
OpenIM.iMManager.messageManager.createImageMessage(
imagePath: '', // 图片相对路径
);
OpenIM.iMManager.messageManager.createImageMessageFromFullPath(
imagePath: '', // 图片的绝对路径
);
OpenIM.iMManager.messageManager.createSoundMessage(
soundPath: '', // 相对路径
duration: 0, // 时长
);
OpenIM.iMManager.messageManager.createSoundMessageFromFullPath(
soundPath: '', // 绝对路径
duration: 0, // 时长
);
OpenIM.iMManager.messageManager.createVideoMessage(
videoPath: '', // 相对路径
videoType: '', // minetype
duration: 0, // 时长s
snapshotPath: '', // 站位缩略图
);
OpenIM.iMManager.messageManager.createVideoMessageFromFullPath(
videoPath: '', // 相对路径
videoType: '', // minetype
duration: 0, // 时长s
snapshotPath: '', // 站位缩略图
);
OpenIM.iMManager.messageManager.createFileMessage(
filePath: '', // 相对路径
fileName: '', // 文件名
);
OpenIM.iMManager.messageManager.createFileMessageFromFullPath(
filePath: '', // 相对路径
fileName: '', // 文件名
);
OpenIM.iMManager.messageManager.createForwardMessage(
message: Message(), // 转发消息体
);
OpenIM.iMManager.messageManager.createMergerMessage(
messageList: [], // 被转发的消息列表
title: '', // 标题
summaryList: [], // 每一条消息摘要
);
OpenIM.iMManager.messageManager.createLocationMessage(
latitude: 0, // 纬度
longitude: 0, // 经度
description: '', // 位置描述信息
);
OpenIM.iMManager.messageManager.createCustomMessage(
data: '', // 自定义内容
extension: '', // 扩展信息
description: '', // 描述消息
);
OpenIM.iMManager.messageManager.createQuoteMessage(
text: '', // 回复内容
quoteMsg: Message(), // 被回复的消息体
);
OpenIM.iMManager.messageManager.createCardMessage(
data: {}, // 自定义内容
);
OpenIM.iMManager.messageManager.clearC2CHistoryMessage(
uid: "", // 清空聊天记录
);
OpenIM.iMManager.messageManager.clearGroupHistoryMessage(
gid: '', // 群ID
);
}
} }

View File

@@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.8.1" version: "2.8.2"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@@ -21,7 +21,7 @@ packages:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.2.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
@@ -68,7 +68,7 @@ packages:
path: ".." path: ".."
relative: true relative: true
source: path source: path
version: "1.0.3" version: "1.1.1"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@@ -80,7 +80,14 @@ packages:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10" version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@@ -141,7 +148,7 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.2" version: "0.4.8"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@@ -155,7 +162,7 @@ packages:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.1"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.14.0 <3.0.0"
flutter: ">=1.20.0" flutter: ">=1.20.0"

View File

@@ -1,14 +1,7 @@
//
// BaseCallback.swift
// flutter_openim_sdk
//
// Created by willem on 2021/10/9.
//
import Foundation import Foundation
import OpenIMCore import OpenIMCore
public class BaseCallback: NSObject, Open_im_sdkBaseProtocol { public class BaseCallback: NSObject, Open_im_sdk_callbackBaseProtocol {
private let result:FlutterResult private let result:FlutterResult
@@ -16,7 +9,7 @@ public class BaseCallback: NSObject, Open_im_sdkBaseProtocol {
self.result = result self.result = result
} }
public func onError(_ errCode: Int, errMsg: String?) { public func onError(_ errCode: Int32, errMsg: String?) {
print("BaseResult: " + errMsg!) print("BaseResult: " + errMsg!)
safeMainAsync { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) } safeMainAsync { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
} }

View File

@@ -1,10 +1,9 @@
import Foundation import Foundation
public class CommonUtil { public class CommonUtil {
public static func emitEvent(channel: FlutterMethodChannel, method: String, type: String, errCode: Int?, errMsg: String?, data: Any?){ public static func emitEvent(channel: FlutterMethodChannel, method: String, type: String, errCode: Int32?, errMsg: String?, data: Any?){
safeMainAsync { safeMainAsync {
var res: [String: Any] = [:] var res: [String: Any] = [:]
res["type"] = type res["type"] = type

View File

@@ -1,10 +1,3 @@
//
// JsonUtil.swift
// Runner
//
// Created by z1u24 on 2021/6/28.
//
import Foundation import Foundation
public class JsonUtil { public class JsonUtil {

View File

@@ -1,10 +1,3 @@
//
// BaseServiceManager.swift
// flutter_openim_sdk
//
// Created by willem on 2021/10/9.
//
import Flutter import Flutter
import OpenIMCore import OpenIMCore
import UIKit import UIKit

View File

@@ -1,10 +1,3 @@
//
// ConversationManager.swift
// Runner
//
// Created by z1u24 on 2021/6/29.
//
import Foundation import Foundation
import OpenIMCore import OpenIMCore
@@ -12,18 +5,20 @@ public class ConversationManager: BaseServiceManager {
public override func registerHandlers() { public override func registerHandlers() {
super.registerHandlers() super.registerHandlers()
self["setConversationListener"] = setConversationListener self["setConversationListener"] = setConversationListener
self["getAllConversationList"] = getAllConversationList self["getAllConversationList"] = getAllConversationList
self["getConversationListSplit"] = getConversationListSplit
self["getOneConversation"] = getOneConversation self["getOneConversation"] = getOneConversation
self["getMultipleConversation"] = getMultipleConversation self["getMultipleConversation"] = getMultipleConversation
self["deleteConversation"] = deleteConversation self["deleteConversation"] = deleteConversation
self["setConversationDraft"] = setConversationDraft self["setConversationDraft"] = setConversationDraft
self["pinConversation"] = pinConversation self["pinConversation"] = pinConversation
self["markSingleMessageHasRead"] = markSingleMessageHasRead // self["markSingleMessageHasRead"] = markSingleMessageHasRead
self["markGroupMessageHasRead"] = markGroupMessageHasRead self["markGroupMessageHasRead"] = markGroupMessageHasRead
self["getTotalUnreadMsgCount"] = getTotalUnreadMsgCount self["getTotalUnreadMsgCount"] = getTotalUnreadMsgCount
self["getConversationIDBySessionType"] = getConversationIDBySessionType self["getConversationIDBySessionType"] = getConversationIDBySessionType
self["setConversationRecvMessageOpt"] = setConversationRecvMessageOpt
self["getConversationRecvMessageOpt"] = getConversationRecvMessageOpt
} }
func setConversationListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func setConversationListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
@@ -32,49 +27,61 @@ public class ConversationManager: BaseServiceManager {
} }
func getAllConversationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getAllConversationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetAllConversationList(BaseCallback(result: result)) Open_im_sdkGetAllConversationList(BaseCallback(result: result), methodCall[string: "operationID"])
}
func getConversationListSplit(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetConversationListSplit(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[int: "offset"], methodCall[int: "count"])
} }
func getOneConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getOneConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetOneConversation(methodCall[string: "sourceID"], methodCall[int: "sessionType"], BaseCallback(result: result)) Open_im_sdkGetOneConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[int: "sessionType"], methodCall[string: "sourceID"])
} }
func getMultipleConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getMultipleConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetMultipleConversation(methodCall[jsonString: "conversationIDList"], BaseCallback(result: result)) Open_im_sdkGetMultipleConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "conversationIDList"])
} }
func deleteConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func deleteConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkDeleteConversation(methodCall[string: "conversationID"], BaseCallback(result: result)) Open_im_sdkDeleteConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"])
} }
func setConversationDraft(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func setConversationDraft(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkSetConversationDraft(methodCall[string: "conversationID"], methodCall[string: "draftText"], BaseCallback(result: result)) Open_im_sdkSetConversationDraft(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[string: "draftText"])
} }
func pinConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func pinConversation(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkPinConversation(methodCall[string: "conversationID"], methodCall[bool: "isPinned"], BaseCallback(result: result)) Open_im_sdkPinConversation(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "conversationID"], methodCall[bool: "isPinned"])
} }
func markSingleMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ // func markSingleMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkMarkSingleMessageHasRead(BaseCallback(result: result), methodCall[string: "userID"]) // Open_im_sdkMarkSingleMessageHasRead(BaseCallback(result: result), methodCall[string: "userID"])
} // }
func markGroupMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func markGroupMessageHasRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkMarkGroupMessageHasRead(BaseCallback(result: result), methodCall[string: "groupID"]) Open_im_sdkMarkGroupMessageHasRead(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "groupID"])
} }
func getTotalUnreadMsgCount(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getTotalUnreadMsgCount(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetTotalUnreadMsgCount(BaseCallback(result: result)) Open_im_sdkGetTotalUnreadMsgCount(BaseCallback(result: result), methodCall[string: "operationID"])
} }
func getConversationIDBySessionType(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getConversationIDBySessionType(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let conversationID = Open_im_sdkGetConversationIDBySessionType(methodCall[string: "sourceID"], methodCall[int: "sessionType"]) let conversationID = Open_im_sdkGetConversationIDBySessionType(methodCall[string: "sourceID"], methodCall[int: "sessionType"])
callBack(result, conversationID) callBack(result, conversationID)
} }
func setConversationRecvMessageOpt(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkSetConversationRecvMessageOpt(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "conversationIDList"], methodCall[int: "status"])
}
func getConversationRecvMessageOpt(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetConversationRecvMessageOpt(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "conversationIDList"])
}
} }
public class ConversationListener: NSObject, Open_im_sdkOnConversationListenerProtocol { public class ConversationListener: NSObject, Open_im_sdk_callbackOnConversationListenerProtocol {
private let channel:FlutterMethodChannel private let channel:FlutterMethodChannel

View File

@@ -1,10 +1,3 @@
//
// FriendshipManager.swift
// Runner
//
// Created by z1u24 on 2021/6/29.
//
import Foundation import Foundation
import OpenIMCore import OpenIMCore
@@ -15,14 +8,15 @@ public class FriendshipManager: BaseServiceManager {
self["setFriendListener"] = setFriendListener self["setFriendListener"] = setFriendListener
self["getFriendsInfo"] = getFriendsInfo self["getFriendsInfo"] = getFriendsInfo
self["addFriend"] = addFriend self["addFriend"] = addFriend
self["getFriendApplicationList"] = getFriendApplicationList self["getRecvFriendApplicationList"] = getRecvFriendApplicationList
self["getSendFriendApplicationList"] = getSendFriendApplicationList
self["getFriendList"] = getFriendList self["getFriendList"] = getFriendList
self["setFriendInfo"] = setFriendInfo self["setFriendRemark"] = setFriendRemark
self["addToBlackList"] = addToBlackList self["addBlacklist"] = addBlacklist
self["getBlackList"] = getBlackList self["getBlacklist"] = getBlacklist
self["deleteFromBlackList"] = deleteFromBlackList self["removeBlacklist"] = removeBlacklist
self["checkFriend"] = checkFriend self["checkFriend"] = checkFriend
self["deleteFromFriendList"] = deleteFromFriendList self["deleteFriend"] = deleteFriend
self["acceptFriendApplication"] = acceptFriendApplication self["acceptFriendApplication"] = acceptFriendApplication
self["refuseFriendApplication"] = refuseFriendApplication self["refuseFriendApplication"] = refuseFriendApplication
// self["forceSyncFriendApplication"] = forceSyncFriendApplication // self["forceSyncFriendApplication"] = forceSyncFriendApplication
@@ -36,51 +30,55 @@ public class FriendshipManager: BaseServiceManager {
} }
func getFriendsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getFriendsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetFriendsInfo(BaseCallback(result: result), methodCall[jsonString: "uidList"]) Open_im_sdkGetDesignatedFriendsInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "uidList"])
} }
func addFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func addFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkAddFriend(BaseCallback(result: result), methodCall.toJsonString()) Open_im_sdkAddFriend(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
} }
func getFriendApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getRecvFriendApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetFriendApplicationList(BaseCallback(result: result)) Open_im_sdkGetRecvFriendApplicationList(BaseCallback(result: result), methodCall[string: "operationID"])
}
func getSendFriendApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetSendFriendApplicationList(BaseCallback(result: result), methodCall[string: "operationID"])
} }
func getFriendList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getFriendList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetFriendList(BaseCallback(result: result)) Open_im_sdkGetFriendList(BaseCallback(result: result), methodCall[string: "operationID"])
} }
func setFriendInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func setFriendRemark(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkSetFriendInfo(methodCall.toJsonString(), BaseCallback(result: result)) Open_im_sdkSetFriendRemark(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
} }
func addToBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func addBlacklist(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkAddToBlackList(BaseCallback(result: result), methodCall[jsonString: "uid"]) Open_im_sdkAddBlack(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "uid"])
} }
func getBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getBlacklist(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetBlackList(BaseCallback(result: result)) Open_im_sdkGetBlackList(BaseCallback(result: result), methodCall[string: "operationID"])
} }
func deleteFromBlackList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func removeBlacklist(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkDeleteFromBlackList(BaseCallback(result: result), methodCall[jsonString: "uid"]) Open_im_sdkRemoveBlack(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "uid"])
} }
func checkFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func checkFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkCheckFriend(BaseCallback(result: result), methodCall[jsonString: "uidList"]) Open_im_sdkCheckFriend(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "uidList"])
} }
func deleteFromFriendList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func deleteFriend(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkDeleteFromFriendList(methodCall[jsonString: "uid"], BaseCallback(result: result)) Open_im_sdkDeleteFriend(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "uid"])
} }
func acceptFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func acceptFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkAcceptFriendApplication(BaseCallback(result: result), methodCall[jsonString: "uid"]) Open_im_sdkAcceptFriendApplication(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
} }
func refuseFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func refuseFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkRefuseFriendApplication(BaseCallback(result: result), methodCall[jsonString: "uid"]) Open_im_sdkRefuseFriendApplication(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
} }
// func forceSyncFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ // func forceSyncFriendApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
@@ -99,48 +97,47 @@ public class FriendshipManager: BaseServiceManager {
// } // }
} }
public class FriendshipListener: NSObject, Open_im_sdkOnFriendshipListenerProtocol { public class FriendshipListener: NSObject, Open_im_sdk_callbackOnFriendshipListenerProtocol {
private let channel:FlutterMethodChannel private let channel:FlutterMethodChannel
init(channel:FlutterMethodChannel) { init(channel:FlutterMethodChannel) {
self.channel = channel self.channel = channel
} }
public func onBlackListAdd(_ userInfo: String?) { public func onBlackAdded(_ blackInfo: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlackListAdd", errCode: nil, errMsg: nil, data: userInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlacklistAdded", errCode: nil, errMsg: nil, data: blackInfo)
} }
public func onBlackListDeleted(_ userInfo: String?) { public func onBlackDeleted(_ blackInfo: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlackListDeleted", errCode: nil, errMsg: nil, data: userInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onBlacklistDeleted", errCode: nil, errMsg: nil, data: blackInfo)
} }
public func onFriendApplicationListAccept(_ applyUserInfo: String?) { public func onFriendApplicationAccepted(_ friendApplication: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationListAccept", errCode: nil, errMsg: nil, data: applyUserInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationAccepted", errCode: nil, errMsg: nil, data: friendApplication)
} }
public func onFriendApplicationListAdded(_ applyUserInfo: String?) { public func onFriendApplicationAdded(_ friendApplication: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationListAdded", errCode: nil, errMsg: nil, data: applyUserInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationAdded", errCode: nil, errMsg: nil, data: friendApplication)
} }
public func onFriendApplicationListDeleted(_ applyUserInfo: String?) { public func onFriendApplicationDeleted(_ friendApplication: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationListDeleted", errCode: nil, errMsg: nil, data: applyUserInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationDeleted", errCode: nil, errMsg: nil, data: friendApplication)
} }
public func onFriendApplicationListReject(_ applyUserInfo: String?) { public func onFriendApplicationRejected(_ friendApplication: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationListReject", errCode: nil, errMsg: nil, data: applyUserInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendApplicationRejected", errCode: nil, errMsg: nil, data: friendApplication)
} }
public func onFriendInfoChanged(_ friendInfo: String?) { public func onFriendInfoChanged(_ friendInfo: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendInfoChanged", errCode: nil, errMsg: nil, data: friendInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendInfoChanged", errCode: nil, errMsg: nil, data: friendInfo)
} }
public func onFriendListAdded(_ friendInfo: String?) { public func onFriendAdded(_ friendInfo: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendListAdded", errCode: nil, errMsg: nil, data: friendInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendAdded", errCode: nil, errMsg: nil, data: friendInfo)
} }
public func onFriendListDeleted(_ friendInfo: String?) { public func onFriendDeleted(_ friendInfo: String?) {
CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendListDeleted", errCode: nil, errMsg: nil, data: friendInfo) CommonUtil.emitEvent(channel: channel, method: "friendListener", type: "onFriendDeleted", errCode: nil, errMsg: nil, data: friendInfo)
} }
} }

View File

@@ -1,10 +1,3 @@
//
// GroupManager.swift
// flutter_openim_sdk
//
// Created by z1u24 on 2021/7/5.
//
import Foundation import Foundation
import OpenIMCore import OpenIMCore
@@ -24,7 +17,8 @@ public class GroupManager: BaseServiceManager {
self["joinGroup"] = joinGroup self["joinGroup"] = joinGroup
self["quitGroup"] = quitGroup self["quitGroup"] = quitGroup
self["transferGroupOwner"] = transferGroupOwner self["transferGroupOwner"] = transferGroupOwner
self["getGroupApplicationList"] = getGroupApplicationList self["getRecvGroupApplicationList"] = getRecvGroupApplicationList
self["getSendGroupApplicationList"] = getSendGroupApplicationList
self["acceptGroupApplication"] = acceptGroupApplication self["acceptGroupApplication"] = acceptGroupApplication
self["refuseGroupApplication"] = refuseGroupApplication self["refuseGroupApplication"] = refuseGroupApplication
// self["forceSyncApplyGroupRequest"] = forceSyncApplyGroupRequest // self["forceSyncApplyGroupRequest"] = forceSyncApplyGroupRequest
@@ -39,62 +33,66 @@ public class GroupManager: BaseServiceManager {
} }
func inviteUserToGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func inviteUserToGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkInviteUserToGroup(methodCall[string: "gid"], methodCall[string: "reason"], Open_im_sdkInviteUserToGroup(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[string: "reason"],
methodCall[jsonString: "uidList"], BaseCallback(result: result)) methodCall[jsonString: "uidList"])
} }
func kickGroupMember(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func kickGroupMember(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkKickGroupMember(methodCall[string: "gid"], methodCall[string: "reason"], Open_im_sdkKickGroupMember(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[string: "reason"],
methodCall[jsonString: "uidList"], BaseCallback(result: result)) methodCall[jsonString: "uidList"])
} }
func getGroupMembersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getGroupMembersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetGroupMembersInfo(methodCall[string: "gid"], methodCall[jsonString: "uidList"], BaseCallback(result: result)) Open_im_sdkGetGroupMembersInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[jsonString: "uidList"])
} }
func getGroupMemberList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getGroupMemberList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetGroupMemberList(methodCall[string: "gid"], methodCall[int32: "filter"], Open_im_sdkGetGroupMemberList(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[int32: "filter"],
methodCall[int32: "next"], BaseCallback(result: result)) methodCall[int32: "offset"], methodCall[int32: "count"])
} }
func getJoinedGroupList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getJoinedGroupList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetJoinedGroupList(BaseCallback(result: result)) Open_im_sdkGetJoinedGroupList(BaseCallback(result: result), methodCall[string: "operationID"])
} }
func createGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkCreateGroup(methodCall[jsonString: "gInfo"], methodCall[jsonString: "memberList"], BaseCallback(result: result)) Open_im_sdkCreateGroup(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "gInfo"], methodCall[jsonString: "memberList"])
} }
func setGroupInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func setGroupInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkSetGroupInfo(methodCall[jsonString: "gInfo"], BaseCallback(result: result)) Open_im_sdkSetGroupInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[jsonString: "gInfo"])
} }
func getGroupsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getGroupsInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetGroupsInfo(methodCall[jsonString: "gidList"], BaseCallback(result: result)) Open_im_sdkGetGroupsInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "gidList"])
} }
func joinGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func joinGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkJoinGroup(methodCall[string: "gid"], methodCall[string: "reason"], BaseCallback(result: result)) Open_im_sdkJoinGroup(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[string: "reason"])
} }
func quitGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func quitGroup(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkQuitGroup(methodCall[string: "gid"], BaseCallback(result: result)) Open_im_sdkQuitGroup(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"])
} }
func transferGroupOwner(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func transferGroupOwner(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkTransferGroupOwner(methodCall[string: "gid"], methodCall[string: "uid"], BaseCallback(result: result)) Open_im_sdkTransferGroupOwner(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[string: "uid"])
} }
func getGroupApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getRecvGroupApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetGroupApplicationList(BaseCallback(result: result)) Open_im_sdkGetRecvGroupApplicationList(BaseCallback(result: result), methodCall[string: "operationID"])
}
func getSendGroupApplicationList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetSendGroupApplicationList(BaseCallback(result: result), methodCall[string: "operationID"])
} }
func acceptGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func acceptGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkAcceptGroupApplication(methodCall[jsonString: "application"], methodCall[string: "reason"], BaseCallback(result: result)) Open_im_sdkAcceptGroupApplication(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[string: "uid"], methodCall[string: "handleMsg"])
} }
func refuseGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func refuseGroupApplication(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkRefuseGroupApplication(methodCall[jsonString: "application"], methodCall[string: "reason"], BaseCallback(result: result)) Open_im_sdkRefuseGroupApplication(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "gid"], methodCall[string: "uid"], methodCall[string: "handleMsg"])
} }
// func forceSyncApplyGroupRequest(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { // func forceSyncApplyGroupRequest(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
@@ -118,7 +116,7 @@ public class GroupManager: BaseServiceManager {
// } // }
} }
public class GroupListener: NSObject, Open_im_sdkOnGroupListenerProtocol { public class GroupListener: NSObject, Open_im_sdk_callbackOnGroupListenerProtocol {
private let channel:FlutterMethodChannel private let channel:FlutterMethodChannel
@@ -126,73 +124,43 @@ public class GroupListener: NSObject, Open_im_sdkOnGroupListenerProtocol {
self.channel = channel self.channel = channel
} }
public func onApplicationProcessed(_ groupId: String?, opUser: String?, agreeOrReject AgreeOrReject: Int32, opReason: String?) { public func onGroupApplicationAccepted(_ s: String?) {
var values: [String: Any] = [:] CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupApplicationAccepted", errCode: nil, errMsg: nil, data: s)
values["groupId"] = groupId
values["opUser"] = opUser
values["agreeOrReject"] = AgreeOrReject
values["opReason"] = opReason
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onApplicationProcessed", errCode: nil, errMsg: nil, data: values)
} }
// public func onApplicationProcessed(_ s: String?,s1: String?,i: Int?,s2: String?) { public func onGroupApplicationAdded(_ s: String?) {
// let values: NSMutableDictionary = NSMutableDictionary(capacity: 0) CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupApplicationAdded", errCode: nil, errMsg: nil, data: s)
// values.setValue(s, forKey: "groupId")
// values.setValue(s1, forKey: "opUser")
// values.setValue(i, forKey: "agreeOrReject")
// values.setValue(s2, forKey: "opReason")
// CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onApplicationProcessed", errCode: nil, errMsg: nil, data: values)
// }
public func onGroupCreated(_ s: String?) {
var values: [String: Any] = [:]
values["groupId"] = s
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupCreated", errCode: nil, errMsg: nil, data: values)
} }
public func onGroupInfoChanged(_ s: String?, groupInfo s1: String?) { public func onGroupApplicationDeleted(_ s: String?) {
var values: [String: Any] = [:] CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupApplicationDeleted", errCode: nil, errMsg: nil, data: s)
values["groupId"] = s
values["groupInfo"] = s1
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupInfoChanged", errCode: nil, errMsg: nil, data: values)
} }
public func onMemberEnter(_ s: String?, memberList s1: String?) { public func onGroupApplicationRejected(_ s: String?) {
var values: [String: Any] = [:] CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupApplicationRejected", errCode: nil, errMsg: nil, data: s)
values["groupId"] = s
values["memberList"] = s1
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onMemberEnter", errCode: nil, errMsg: nil, data: values)
} }
public func onMemberInvited(_ s: String?,opUser s1: String?, memberList s2: String?) { public func onGroupInfoChanged(_ s: String?) {
var values: [String: Any] = [:] CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupInfoChanged", errCode: nil, errMsg: nil, data: s)
values["groupId"] = s
values["opUser"] = s1
values["memberList"] = s2
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onMemberInvited", errCode: nil, errMsg: nil, data: values)
} }
public func onMemberKicked(_ s: String?,opUser s1: String?,memberList s2: String?) { public func onGroupMemberAdded(_ s: String?) {
var values: [String: Any] = [:] CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupMemberAdded", errCode: nil, errMsg: nil, data: s)
values["groupId"] = s
values["opUser"] = s1
values["memberList"] = s2
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onMemberKicked", errCode: nil, errMsg: nil, data: values)
} }
public func onMemberLeave(_ s: String?,member s1: String?) { public func onGroupMemberDeleted(_ s: String?) {
var values: [String: Any] = [:] CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupMemberDeleted", errCode: nil, errMsg: nil, data: s)
values["groupId"] = s
values["member"] = s1
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onMemberLeave", errCode: nil, errMsg: nil, data: values)
} }
public func onReceiveJoinApplication(_ s: String?,member s1: String?,opReason s2: String?) { public func onGroupMemberInfoChanged(_ s: String?) {
var values: [String: Any] = [:] CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onGroupMemberInfoChanged", errCode: nil, errMsg: nil, data: s)
values["groupId"] = s
values["member"] = s1
values["opReason"] = s2
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onReceiveJoinApplication", errCode: nil, errMsg: nil, data: values)
} }
public func onJoinedGroupAdded(_ s: String?) {
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onJoinedGroupAdded", errCode: nil, errMsg: nil, data: s)
}
public func onJoinedGroupDeleted(_ s: String?) {
CommonUtil.emitEvent(channel: channel, method: "groupListener", type: "onJoinedGroupDeleted", errCode: nil, errMsg: nil, data: s)
}
} }

View File

@@ -1,10 +1,3 @@
//
// IMManager.swift
// Runner
//
// Created by z1u24 on 2021/6/28.
//
import Foundation import Foundation
import OpenIMCore import OpenIMCore
@@ -12,30 +5,29 @@ public class IMMananger: BaseServiceManager {
public override func registerHandlers() { public override func registerHandlers() {
super.registerHandlers() super.registerHandlers()
self["initSDK"] = initSDK self["initSDK"] = initSDK
self["login"] = login self["login"] = login
self["logout"] = logout self["logout"] = logout
self["getLoginStatus"] = getLoginStatus self["getLoginStatus"] = getLoginStatus
// self["getLoginUid"] = getLoginUid // self["getLoginUid"] = getLoginUid
self["getUsersInfo"] = getUsersInfo // self["getUsersInfo"] = getUsersInfo
self["setSelfInfo"] = setSelfInfo // self["setSelfInfo"] = setSelfInfo
self["forceSyncLoginUerInfo"] = forceSyncLoginUerInfo // self["forceSyncLoginUerInfo"] = forceSyncLoginUerInfo
// self["forceReConn"] = forceReConn // self["forceReConn"] = forceReConn
self["setSdkLog"] = setSdkLog // self["setSdkLog"] = setSdkLog
} }
func initSDK(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func initSDK(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkInitSDK(methodCall.toJsonString(), SDKListener(channel: self.channel)) Open_im_sdkInitSDK(ConnListener(channel: self.channel), methodCall[string: "operationID"], methodCall.toJsonString())
callBack(result) callBack(result)
} }
func login(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { func login(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkLogin(methodCall[string: "uid"], methodCall[string: "token"], BaseCallback(result: result)) Open_im_sdkLogin(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "uid"], methodCall[string: "token"])
} }
func logout(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { func logout(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkLogout(BaseCallback(result: result)) Open_im_sdkLogout(BaseCallback(result: result), methodCall[string: "operationID"])
} }
func getLoginStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { func getLoginStatus(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
@@ -46,56 +38,52 @@ public class IMMananger: BaseServiceManager {
// callBack(result, Open_im_sdkGetLoginUser()) // callBack(result, Open_im_sdkGetLoginUser())
// } // }
func getUsersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { // func getUsersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkGetUsersInfo(methodCall[jsonString: "uidList"], BaseCallback(result: result)) // Open_im_sdkGetUsersInfo(methodCall[jsonString: "uidList"], BaseCallback(result: result))
} // }
func setSelfInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { // func setSelfInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkSetSelfInfo(methodCall.toJsonString(), BaseCallback(result: result)) // Open_im_sdkSetSelfInfo(methodCall.toJsonString(), BaseCallback(result: result))
} // }
func forceSyncLoginUerInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { // func forceSyncLoginUerInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkForceSyncLoginUerInfo() // Open_im_sdkForceSyncLoginUerInfo()
callBack(result) // callBack(result)
} // }
func setSdkLog(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { // func setSdkLog(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkSetSdkLog(methodCall[int32: "sdkLog"]) // Open_im_sdkSetSdkLog(methodCall[int32: "sdkLog"])
} // }
// func forceReConn(methodCall: FlutterMethodCall, result: @escaping FlutterResult) { // func forceReConn(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
// Open_im_sdkForceReConn() // Open_im_sdkForceReConn()
// callBack(result) // callBack(result)
// } // }
} }
public class SDKListener: NSObject, Open_im_sdkIMSDKListenerProtocol { public class ConnListener: NSObject, Open_im_sdk_callbackOnConnListenerProtocol {
private let channel:FlutterMethodChannel private let channel:FlutterMethodChannel
init(channel:FlutterMethodChannel) { init(channel:FlutterMethodChannel) {
self.channel = channel self.channel = channel
} }
public func onConnectFailed(_ errCode: Int, errMsg: String?) { public func onConnectFailed(_ errCode: Int32, errMsg: String?) {
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onConnectFailed", errCode: errCode, errMsg: errMsg, data: nil) CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onConnectFailed", errCode: errCode, errMsg: errMsg, data: nil)
} }
public func onConnectSuccess() { public func onConnectSuccess() {
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onConnectSuccess", errCode: nil, errMsg: nil, data: nil) CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onConnectSuccess", errCode: nil, errMsg: nil, data: nil)
} }
public func onConnecting() { public func onConnecting() {
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onConnecting", errCode: nil, errMsg: nil, data: nil) CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onConnecting", errCode: nil, errMsg: nil, data: nil)
} }
public func onKickedOffline() { public func onKickedOffline() {
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onKickedOffline", errCode: nil, errMsg: nil, data: nil) CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onKickedOffline", errCode: nil, errMsg: nil, data: nil)
}
public func onSelfInfoUpdated(_ userInfo: String?) {
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onSelfInfoUpdated", errCode: nil, errMsg: nil, data: userInfo)
} }
public func onUserTokenExpired() { public func onUserTokenExpired() {
CommonUtil.emitEvent(channel: self.channel, method: "initSDKListener", type: "onUserTokenExpired", errCode: nil, errMsg: nil, data: nil) CommonUtil.emitEvent(channel: self.channel, method: "connectListener", type: "onUserTokenExpired", errCode: nil, errMsg: nil, data: nil)
} }
} }

View File

@@ -1,29 +1,20 @@
//
// MessageManager.swift
// Runner
//
// Created by z1u24 on 2021/6/29.
//
import Foundation import Foundation
import OpenIMCore import OpenIMCore
public class MessageManager: BaseServiceManager { public class MessageManager: BaseServiceManager {
private let KEY_ID: String = "id" private let KEY_ID: String = "id"
private var listeners: [String: AdvancedMsgListener] = [:] // private var listeners: [String: AdvancedMsgListener] = [:]
public override func registerHandlers() { public override func registerHandlers() {
super.registerHandlers() super.registerHandlers()
self["setAdvancedMsgListener"] = setAdvancedMsgListener
self["addAdvancedMsgListener"] = addAdvancedMsgListener
self["removeAdvancedMsgListener"] = removeAdvancedMsgListener
self["sendMessage"] = sendMessage self["sendMessage"] = sendMessage
self["getHistoryMessageList"] = getHistoryMessageList self["getHistoryMessageList"] = getHistoryMessageList
self["revokeMessage"] = revokeMessage self["revokeMessage"] = revokeMessage
self["deleteMessageFromLocalStorage"] = deleteMessageFromLocalStorage self["deleteMessageFromLocalStorage"] = deleteMessageFromLocalStorage
self["deleteMessages"] = deleteMessages self["deleteMessages"] = deleteMessages
self["insertSingleMessageToLocalStorage"] = insertSingleMessageToLocalStorage self["insertSingleMessageToLocalStorage"] = insertSingleMessageToLocalStorage
self["findMessages"] = findMessages // self["findMessages"] = findMessages
self["markC2CMessageAsRead"] = markC2CMessageAsRead self["markC2CMessageAsRead"] = markC2CMessageAsRead
self["typingStatusUpdate"] = typingStatusUpdate self["typingStatusUpdate"] = typingStatusUpdate
self["createTextMessage"] = createTextMessage self["createTextMessage"] = createTextMessage
@@ -35,56 +26,41 @@ public class MessageManager: BaseServiceManager {
self["createVideoMessage"] = createVideoMessage self["createVideoMessage"] = createVideoMessage
self["createVideoMessageFromFullPath"] = createVideoMessageFromFullPath self["createVideoMessageFromFullPath"] = createVideoMessageFromFullPath
self["createFileMessage"] = createFileMessage self["createFileMessage"] = createFileMessage
self["createFileMessageFromFullPath"] = createFileMessageFromFullPath
self["createMergerMessage"] = createMergerMessage self["createMergerMessage"] = createMergerMessage
self["createForwardMessage"] = createForwardMessage self["createForwardMessage"] = createForwardMessage
self["createLocationMessage"] = createLocationMessage self["createLocationMessage"] = createLocationMessage
self["createCustomMessage"] = createCustomMessage self["createCustomMessage"] = createCustomMessage
self["createQuoteMessage"] = createQuoteMessage self["createQuoteMessage"] = createQuoteMessage
self["createCardMessage"] = createCardMessage self["createCardMessage"] = createCardMessage
self["forceSyncMsg"] = forceSyncMsg // self["forceSyncMsg"] = forceSyncMsg
self["clearC2CHistoryMessage"] = clearC2CHistoryMessage self["clearC2CHistoryMessage"] = clearC2CHistoryMessage
self["clearGroupHistoryMessage"] = clearGroupHistoryMessage self["clearGroupHistoryMessage"] = clearGroupHistoryMessage
} }
func addAdvancedMsgListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func setAdvancedMsgListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let key = methodCall[string: KEY_ID] let key = methodCall[string: KEY_ID]
if listeners[key] == nil {
let lis = AdvancedMsgListener(channel: channel, id: key) let lis = AdvancedMsgListener(channel: channel, id: key)
listeners[key] = lis Open_im_sdkSetAdvancedMsgListener(lis)
Open_im_sdkAddAdvancedMsgListener(lis)
print("=================add msg listener======\n\(lis)")
}
callBack(result)
}
func removeAdvancedMsgListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let key = methodCall[string: KEY_ID]
if let lis = listeners[key] {
listeners[key] = nil
// Open_im_sdkRemoveAdvancedMsgListener(lis)
}
callBack(result) callBack(result)
} }
func sendMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func sendMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let sendMsgProgressListener: SendMsgProgressListener = SendMsgProgressListener(channel: channel) let sendMsgProgressListener: SendMsgProgressListener = SendMsgProgressListener(channel: channel,result: result,methodCall: methodCall)
sendMsgProgressListener.setCall(methodCall: methodCall) Open_im_sdkSendMessage(sendMsgProgressListener, methodCall[string: "operationID"], methodCall[jsonString: "message"], methodCall[string: "userID"],
sendMsgProgressListener.setResult(result: result) methodCall[string: "groupID"], methodCall[jsonString: "offlinePushInfo"])
print("===============sendMessage===============")
Open_im_sdkSendMessage(sendMsgProgressListener, methodCall[jsonString: "message"], methodCall[string: "receiver"],
methodCall[string: "groupID"], methodCall[bool: "onlineUserOnly"])
} }
func getHistoryMessageList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func getHistoryMessageList(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkGetHistoryMessageList(BaseCallback(result: result), methodCall.toJsonString()) Open_im_sdkGetHistoryMessageList(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
} }
func revokeMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func revokeMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkRevokeMessage(BaseCallback(result: result), methodCall.toJsonString()) Open_im_sdkRevokeMessage(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
} }
func deleteMessageFromLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func deleteMessageFromLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkDeleteMessageFromLocalStorage(BaseCallback(result: result), methodCall.toJsonString()) Open_im_sdkDeleteMessageFromLocalStorage(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
} }
// deprecated // deprecated
@@ -92,162 +68,146 @@ public class MessageManager: BaseServiceManager {
} }
func insertSingleMessageToLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func insertSingleMessageToLocalStorage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkInsertSingleMessageToLocalStorage(BaseCallback(result: result), methodCall[jsonString: "message"], Open_im_sdkInsertSingleMessageToLocalStorage(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "message"],
methodCall[string: "userID"], methodCall[string: "sender"]) methodCall[string: "receiverID"], methodCall[string: "senderID"])
} }
func findMessages(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ // func findMessages(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkFindMessages(BaseCallback(result: result), methodCall[jsonString: "messageIDList"]) // Open_im_sdkFindMessages(BaseCallback(result: result), methodCall[jsonString: "messageIDList"])
} // }
func markC2CMessageAsRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func markC2CMessageAsRead(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkMarkC2CMessageAsRead(BaseCallback(result: result), methodCall[string: "userID"], methodCall[jsonString: "messageIDList"]) Open_im_sdkMarkC2CMessageAsRead(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "userID"], methodCall[jsonString: "messageIDList"])
} }
func typingStatusUpdate(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func typingStatusUpdate(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkTypingStatusUpdate(methodCall[string: "userID"], methodCall[string: "typing"]) Open_im_sdkTypingStatusUpdate(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "userID"], methodCall[string: "msgTip"])
callBack(result)
} }
func createTextMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createTextMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateTextMessage(methodCall[string: "text"])) callBack(result, Open_im_sdkCreateTextMessage(methodCall[string: "operationID"], methodCall[string: "text"]))
} }
func createTextAtMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createTextAtMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateTextAtMessage(methodCall[string: "text"], methodCall[jsonString: "atUserList"])) callBack(result, Open_im_sdkCreateTextAtMessage(methodCall[string: "operationID"], methodCall[string: "text"], methodCall[jsonString: "atUserList"]))
} }
func createImageMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createImageMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateImageMessage(methodCall[string: "imagePath"])) callBack(result, Open_im_sdkCreateImageMessage(methodCall[string: "operationID"], methodCall[string: "imagePath"]))
} }
func createImageMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createImageMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateImageMessageFromFullPath(methodCall[string: "imagePath"])) callBack(result, Open_im_sdkCreateImageMessageFromFullPath(methodCall[string: "operationID"], methodCall[string: "imagePath"]))
} }
func createSoundMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createSoundMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateSoundMessage(methodCall[string: "soundPath"], methodCall[int64: "duration"])) callBack(result, Open_im_sdkCreateSoundMessage(methodCall[string: "operationID"], methodCall[string: "soundPath"], methodCall[int64: "duration"]))
} }
func createSoundMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createSoundMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateSoundMessageFromFullPath(methodCall[string: "soundPath"], methodCall[int64: "duration"])) callBack(result, Open_im_sdkCreateSoundMessageFromFullPath(methodCall[string: "operationID"], methodCall[string: "soundPath"], methodCall[int64: "duration"]))
} }
func createVideoMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createVideoMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let prama = Open_im_sdkCreateVideoMessage(methodCall[string: "videoPath"], methodCall[string: "videoType"], let prama = Open_im_sdkCreateVideoMessage(methodCall[string: "operationID"], methodCall[string: "videoPath"], methodCall[string: "videoType"],
methodCall[int64: "duration"], methodCall[string: "snapshotPath"]) methodCall[int64: "duration"], methodCall[string: "snapshotPath"])
callBack(result, prama) callBack(result, prama)
} }
func createVideoMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createVideoMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let prama = Open_im_sdkCreateVideoMessageFromFullPath(methodCall[string: "videoPath"], methodCall[string: "videoType"], let prama = Open_im_sdkCreateVideoMessageFromFullPath(methodCall[string: "operationID"], methodCall[string: "videoPath"], methodCall[string: "videoType"],
methodCall[int64: "duration"], methodCall[string: "snapshotPath"]) methodCall[int64: "duration"], methodCall[string: "snapshotPath"])
callBack(result, prama) callBack(result, prama)
} }
func createFileMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createFileMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateFileMessage(methodCall[string: "filePath"], methodCall[string: "fileName"])) callBack(result, Open_im_sdkCreateFileMessage(methodCall[string: "operationID"], methodCall[string: "filePath"], methodCall[string: "fileName"]))
} }
func createFileMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createFileMessageFromFullPath(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateFileMessageFromFullPath(methodCall[string: "filePath"], methodCall[string: "fileName"])) callBack(result, Open_im_sdkCreateFileMessageFromFullPath(methodCall[string: "operationID"], methodCall[string: "filePath"], methodCall[string: "fileName"]))
} }
func createMergerMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createMergerMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let prama = Open_im_sdkCreateMergerMessage(methodCall[jsonString: "messageList"], methodCall[string: "title"], let prama = Open_im_sdkCreateMergerMessage(methodCall[string: "operationID"], methodCall[jsonString: "messageList"], methodCall[string: "title"],
methodCall[jsonString: "summaryList"]) methodCall[jsonString: "summaryList"])
callBack(result, prama) callBack(result, prama)
} }
func createForwardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createForwardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateForwardMessage(methodCall[jsonString: "message"])) callBack(result, Open_im_sdkCreateForwardMessage(methodCall[string: "operationID"], methodCall[jsonString: "message"]))
} }
func createLocationMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createLocationMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let prama = Open_im_sdkCreateLocationMessage(methodCall[string: "description"], let prama = Open_im_sdkCreateLocationMessage(methodCall[string: "operationID"], methodCall[string: "description"],
methodCall[double: "longitude"], methodCall[double: "latitude"]) methodCall[double: "longitude"], methodCall[double: "latitude"])
callBack(result, prama) callBack(result, prama)
} }
func createCustomMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createCustomMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let prama = Open_im_sdkCreateCustomMessage(methodCall[string: "data"], let prama = Open_im_sdkCreateCustomMessage(methodCall[string: "operationID"], methodCall[string: "data"],
methodCall[string: "extension"], methodCall[string: "description"]) methodCall[string: "extension"], methodCall[string: "description"])
callBack(result, prama) callBack(result, prama)
} }
func createQuoteMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createQuoteMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
let prama = Open_im_sdkCreateQuoteMessage(methodCall[string: "quoteText"], methodCall[jsonString: "quoteMessage"]) let prama = Open_im_sdkCreateQuoteMessage(methodCall[string: "operationID"], methodCall[string: "quoteText"], methodCall[jsonString: "quoteMessage"])
callBack(result, prama) callBack(result, prama)
} }
func createCardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func createCardMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
callBack(result, Open_im_sdkCreateCardMessage(methodCall[jsonString: "cardMessage"])) callBack(result, Open_im_sdkCreateCardMessage(methodCall[string: "operationID"], methodCall[jsonString: "cardMessage"]))
} }
func forceSyncMsg(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ // func forceSyncMsg(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkForceSyncMsg() // Open_im_sdkForceSyncMsg()
callBack(result) // callBack(result)
} // }
func clearC2CHistoryMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func clearC2CHistoryMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkClearC2CHistoryMessage(BaseCallback(result: result), methodCall[string: "userID"]) Open_im_sdkClearC2CHistoryMessage(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "userID"])
} }
func clearGroupHistoryMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){ func clearGroupHistoryMessage(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkClearGroupHistoryMessage(BaseCallback(result: result), methodCall[string: "groupID"]) Open_im_sdkClearGroupHistoryMessage(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[string: "groupID"])
} }
public class SendMsgProgressListener: NSObject, Open_im_sdkSendMsgCallBackProtocol { public class SendMsgProgressListener: NSObject, Open_im_sdk_callbackSendMsgCallBackProtocol {
private let channel: FlutterMethodChannel private let channel: FlutterMethodChannel
private var result: FlutterResult? private let result: FlutterResult
private var call: FlutterMethodCall? private let call: FlutterMethodCall
private var values: [String: Any] = [:]
init(channel: FlutterMethodChannel) { init(channel: FlutterMethodChannel, result: @escaping FlutterResult, methodCall: FlutterMethodCall) {
self.channel = channel self.channel = channel
}
func setResult(result: @escaping FlutterResult){
self.result = result self.result = result
}
func setCall(methodCall: FlutterMethodCall){
self.call = methodCall self.call = methodCall
} }
public func onError(_ errCode: Int, errMsg: String?) { public func onError(_ errCode: Int32, errMsg: String?) {
print("=================onError============\nerrcode:\(errCode),errMsg:\(errMsg!)") DispatchQueue.main.async { self.result(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
DispatchQueue.main.async { self.result!(FlutterError(code: "\(errCode)", message: errMsg, details: nil)) }
} }
public func onProgress(_ progress: Int) { public func onProgress(_ progress: Int) {
guard let call = call else { var values: [String: Any] = [:]
return let message = call[dict: "message"]
} values["clientMsgID"] = message["clientMsgID"]
print("=================onProgress============\nprogress:\(progress)")
values["clientMsgID"] = call[string: "clientMsgID"]
values["progress"] = progress values["progress"] = progress
CommonUtil.emitEvent(channel: channel, method: "msgSendProgressListener", type: "onProgress", errCode: nil, errMsg: nil, data: values) CommonUtil.emitEvent(channel: channel, method: "msgSendProgressListener", type: "onProgress", errCode: nil, errMsg: nil, data: values)
} }
public func onSuccess(_ data: String?) { public func onSuccess(_ data: String?) {
print("=================onSuccess============\nsuccess:\(data!)") DispatchQueue.main.async { self.result(data) }
DispatchQueue.main.async { self.result!(data) }
} }
} }
public class AdvancedMsgListener: NSObject, Open_im_sdkOnAdvancedMsgListenerProtocol { public class AdvancedMsgListener: NSObject, Open_im_sdk_callbackOnAdvancedMsgListenerProtocol {
private let channel: FlutterMethodChannel private let channel: FlutterMethodChannel
private let id: String private let id: String
// private var values: [String: Any] = [:]
init(channel: FlutterMethodChannel, id: String) { init(channel: FlutterMethodChannel, id: String) {
self.channel = channel self.channel = channel
self.id = id self.id = id
// values["id"] = id
} }
public func onRecvC2CReadReceipt(_ msgReceiptList: String?) { public func onRecvC2CReadReceipt(_ msgReceiptList: String?) {

View File

@@ -0,0 +1,43 @@
import Foundation
import OpenIMCore
public class UserManager: BaseServiceManager {
public override func registerHandlers() {
super.registerHandlers()
self["setUserListener"] = setUserListener
self["getUsersInfo"] = getUsersInfo
self["setSelfInfo"] = setSelfInfo
self["getSelfUserInfo"] = getSelfUserInfo
}
func setUserListener(methodCall: FlutterMethodCall, result: @escaping FlutterResult){
Open_im_sdkSetUserListener(UserListener(channel: channel))
callBack(result)
}
func getUsersInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkGetUsersInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall[jsonString: "uidList"])
}
func setSelfInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkSetSelfInfo(BaseCallback(result: result), methodCall[string: "operationID"], methodCall.toJsonString())
}
func getSelfUserInfo(methodCall: FlutterMethodCall, result: @escaping FlutterResult) {
Open_im_sdkGetSelfUserInfo(BaseCallback(result: result), methodCall[string: "operationID"])
}
}
public class UserListener: NSObject, Open_im_sdk_callbackOnUserListenerProtocol {
private let channel:FlutterMethodChannel
init(channel:FlutterMethodChannel) {
self.channel = channel
}
public func onSelfInfoUpdated(_ userInfo: String?) {
CommonUtil.emitEvent(channel: self.channel, method: "userListener", type: "onSelfInfoUpdated", errCode: nil, errMsg: nil, data: userInfo)
}
}

View File

@@ -2,12 +2,12 @@ import Flutter
import UIKit import UIKit
public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin { public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin {
let imManager: IMMananger let imManager: IMMananger
let conversationManager: ConversationManager let conversationManager: ConversationManager
let friendshipManager: FriendshipManager let friendshipManager: FriendshipManager
let messageManager: MessageManager let messageManager: MessageManager
let groupManager: GroupManager let groupManager: GroupManager
let userManger: UserManager
init(channel: FlutterMethodChannel) { init(channel: FlutterMethodChannel) {
self.imManager = IMMananger(channel: channel) self.imManager = IMMananger(channel: channel)
@@ -15,6 +15,7 @@ public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin {
self.friendshipManager = FriendshipManager(channel: channel) self.friendshipManager = FriendshipManager(channel: channel)
self.messageManager = MessageManager(channel: channel) self.messageManager = MessageManager(channel: channel)
self.groupManager = GroupManager(channel: channel) self.groupManager = GroupManager(channel: channel)
self.userManger = UserManager(channel: channel)
} }
public static func register(with registrar: FlutterPluginRegistrar) { public static func register(with registrar: FlutterPluginRegistrar) {
@@ -36,6 +37,8 @@ public class SwiftFlutterOpenimSdkPlugin: NSObject, FlutterPlugin {
friendshipManager.handleMethod(call: call, result: result) friendshipManager.handleMethod(call: call, result: result)
case "groupManager": case "groupManager":
groupManager.handleMethod(call: call, result: result) groupManager.handleMethod(call: call, result: result)
case "userManager":
userManger.handleMethod(call: call, result: result)
default: default:
print("Handle ManagerName Error: \(managerName) not found") print("Handle ManagerName Error: \(managerName) not found")
} }

View File

@@ -2,12 +2,14 @@
// Objective-C API for talking to the following Go packages // Objective-C API for talking to the following Go packages
// //
// open_im_sdk/open_im_sdk // open_im_sdk/open_im_sdk
// open_im_sdk/open_im_sdk_callback
// //
// File is generated by gomobile bind. Do not edit. // File is generated by gomobile bind. Do not edit.
#ifndef __OpenIMCore_FRAMEWORK_H__ #ifndef __OpenIMCore_FRAMEWORK_H__
#define __OpenIMCore_FRAMEWORK_H__ #define __OpenIMCore_FRAMEWORK_H__
#include "Open_im_sdk.objc.h" #include "Open_im_sdk.objc.h"
#include "Open_im_sdk_callback.objc.h"
#include "Universe.objc.h" #include "Universe.objc.h"
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,205 @@
// Objective-C API for talking to open_im_sdk/open_im_sdk_callback Go package.
// gobind -lang=objc open_im_sdk/open_im_sdk_callback
//
// File is generated by gobind. Do not edit.
#ifndef __Open_im_sdk_callback_H__
#define __Open_im_sdk_callback_H__
@import Foundation;
#include "ref.h"
#include "Universe.objc.h"
@protocol Open_im_sdk_callbackBase;
@class Open_im_sdk_callbackBase;
@protocol Open_im_sdk_callbackOnAdvancedMsgListener;
@class Open_im_sdk_callbackOnAdvancedMsgListener;
@protocol Open_im_sdk_callbackOnConnListener;
@class Open_im_sdk_callbackOnConnListener;
@protocol Open_im_sdk_callbackOnConversationListener;
@class Open_im_sdk_callbackOnConversationListener;
@protocol Open_im_sdk_callbackOnFriendshipListener;
@class Open_im_sdk_callbackOnFriendshipListener;
@protocol Open_im_sdk_callbackOnGroupListener;
@class Open_im_sdk_callbackOnGroupListener;
@protocol Open_im_sdk_callbackOnUserListener;
@class Open_im_sdk_callbackOnUserListener;
@protocol Open_im_sdk_callbackSendMsgCallBack;
@class Open_im_sdk_callbackSendMsgCallBack;
@protocol Open_im_sdk_callbackBase <NSObject>
- (void)onError:(int32_t)errCode errMsg:(NSString* _Nullable)errMsg;
- (void)onSuccess:(NSString* _Nullable)data;
@end
@protocol Open_im_sdk_callbackOnAdvancedMsgListener <NSObject>
- (void)onRecvC2CReadReceipt:(NSString* _Nullable)msgReceiptList;
- (void)onRecvMessageRevoked:(NSString* _Nullable)msgId;
- (void)onRecvNewMessage:(NSString* _Nullable)message;
@end
@protocol Open_im_sdk_callbackOnConnListener <NSObject>
- (void)onConnectFailed:(int32_t)errCode errMsg:(NSString* _Nullable)errMsg;
- (void)onConnectSuccess;
- (void)onConnecting;
- (void)onKickedOffline;
- (void)onUserTokenExpired;
@end
@protocol Open_im_sdk_callbackOnConversationListener <NSObject>
- (void)onConversationChanged:(NSString* _Nullable)conversationList;
- (void)onNewConversation:(NSString* _Nullable)conversationList;
- (void)onSyncServerFailed;
- (void)onSyncServerFinish;
- (void)onSyncServerStart;
- (void)onTotalUnreadMessageCountChanged:(int32_t)totalUnreadCount;
@end
@protocol Open_im_sdk_callbackOnFriendshipListener <NSObject>
- (void)onBlackAdded:(NSString* _Nullable)blackInfo;
- (void)onBlackDeleted:(NSString* _Nullable)blackInfo;
- (void)onFriendAdded:(NSString* _Nullable)friendInfo;
- (void)onFriendApplicationAccepted:(NSString* _Nullable)groupApplication;
- (void)onFriendApplicationAdded:(NSString* _Nullable)friendApplication;
- (void)onFriendApplicationDeleted:(NSString* _Nullable)friendApplication;
- (void)onFriendApplicationRejected:(NSString* _Nullable)friendApplication;
- (void)onFriendDeleted:(NSString* _Nullable)friendInfo;
- (void)onFriendInfoChanged:(NSString* _Nullable)friendInfo;
@end
@protocol Open_im_sdk_callbackOnGroupListener <NSObject>
- (void)onGroupApplicationAccepted:(NSString* _Nullable)groupApplication;
- (void)onGroupApplicationAdded:(NSString* _Nullable)groupApplication;
- (void)onGroupApplicationDeleted:(NSString* _Nullable)groupApplication;
- (void)onGroupApplicationRejected:(NSString* _Nullable)groupApplication;
- (void)onGroupInfoChanged:(NSString* _Nullable)groupInfo;
- (void)onGroupMemberAdded:(NSString* _Nullable)groupMemberInfo;
- (void)onGroupMemberDeleted:(NSString* _Nullable)groupMemberInfo;
- (void)onGroupMemberInfoChanged:(NSString* _Nullable)groupMemberInfo;
- (void)onJoinedGroupAdded:(NSString* _Nullable)groupInfo;
- (void)onJoinedGroupDeleted:(NSString* _Nullable)groupInfo;
@end
@protocol Open_im_sdk_callbackOnUserListener <NSObject>
- (void)onSelfInfoUpdated:(NSString* _Nullable)userInfo;
@end
@protocol Open_im_sdk_callbackSendMsgCallBack <NSObject>
- (void)onError:(int32_t)errCode errMsg:(NSString* _Nullable)errMsg;
- (void)onProgress:(long)progress;
- (void)onSuccess:(NSString* _Nullable)data;
@end
@class Open_im_sdk_callbackBase;
@class Open_im_sdk_callbackOnAdvancedMsgListener;
@class Open_im_sdk_callbackOnConnListener;
@class Open_im_sdk_callbackOnConversationListener;
@class Open_im_sdk_callbackOnFriendshipListener;
@class Open_im_sdk_callbackOnGroupListener;
@class Open_im_sdk_callbackOnUserListener;
@class Open_im_sdk_callbackSendMsgCallBack;
@interface Open_im_sdk_callbackBase : NSObject <goSeqRefInterface, Open_im_sdk_callbackBase> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onError:(int32_t)errCode errMsg:(NSString* _Nullable)errMsg;
- (void)onSuccess:(NSString* _Nullable)data;
@end
@interface Open_im_sdk_callbackOnAdvancedMsgListener : NSObject <goSeqRefInterface, Open_im_sdk_callbackOnAdvancedMsgListener> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onRecvC2CReadReceipt:(NSString* _Nullable)msgReceiptList;
- (void)onRecvMessageRevoked:(NSString* _Nullable)msgId;
- (void)onRecvNewMessage:(NSString* _Nullable)message;
@end
@interface Open_im_sdk_callbackOnConnListener : NSObject <goSeqRefInterface, Open_im_sdk_callbackOnConnListener> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onConnectFailed:(int32_t)errCode errMsg:(NSString* _Nullable)errMsg;
- (void)onConnectSuccess;
- (void)onConnecting;
- (void)onKickedOffline;
- (void)onUserTokenExpired;
@end
@interface Open_im_sdk_callbackOnConversationListener : NSObject <goSeqRefInterface, Open_im_sdk_callbackOnConversationListener> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onConversationChanged:(NSString* _Nullable)conversationList;
- (void)onNewConversation:(NSString* _Nullable)conversationList;
- (void)onSyncServerFailed;
- (void)onSyncServerFinish;
- (void)onSyncServerStart;
- (void)onTotalUnreadMessageCountChanged:(int32_t)totalUnreadCount;
@end
@interface Open_im_sdk_callbackOnFriendshipListener : NSObject <goSeqRefInterface, Open_im_sdk_callbackOnFriendshipListener> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onBlackAdded:(NSString* _Nullable)blackInfo;
- (void)onBlackDeleted:(NSString* _Nullable)blackInfo;
- (void)onFriendAdded:(NSString* _Nullable)friendInfo;
- (void)onFriendApplicationAccepted:(NSString* _Nullable)groupApplication;
- (void)onFriendApplicationAdded:(NSString* _Nullable)friendApplication;
- (void)onFriendApplicationDeleted:(NSString* _Nullable)friendApplication;
- (void)onFriendApplicationRejected:(NSString* _Nullable)friendApplication;
- (void)onFriendDeleted:(NSString* _Nullable)friendInfo;
- (void)onFriendInfoChanged:(NSString* _Nullable)friendInfo;
@end
@interface Open_im_sdk_callbackOnGroupListener : NSObject <goSeqRefInterface, Open_im_sdk_callbackOnGroupListener> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onGroupApplicationAccepted:(NSString* _Nullable)groupApplication;
- (void)onGroupApplicationAdded:(NSString* _Nullable)groupApplication;
- (void)onGroupApplicationDeleted:(NSString* _Nullable)groupApplication;
- (void)onGroupApplicationRejected:(NSString* _Nullable)groupApplication;
- (void)onGroupInfoChanged:(NSString* _Nullable)groupInfo;
- (void)onGroupMemberAdded:(NSString* _Nullable)groupMemberInfo;
- (void)onGroupMemberDeleted:(NSString* _Nullable)groupMemberInfo;
- (void)onGroupMemberInfoChanged:(NSString* _Nullable)groupMemberInfo;
- (void)onJoinedGroupAdded:(NSString* _Nullable)groupInfo;
- (void)onJoinedGroupDeleted:(NSString* _Nullable)groupInfo;
@end
@interface Open_im_sdk_callbackOnUserListener : NSObject <goSeqRefInterface, Open_im_sdk_callbackOnUserListener> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onSelfInfoUpdated:(NSString* _Nullable)userInfo;
@end
@interface Open_im_sdk_callbackSendMsgCallBack : NSObject <goSeqRefInterface, Open_im_sdk_callbackSendMsgCallBack> {
}
@property(strong, readonly) _Nonnull id _ref;
- (nonnull instancetype)initWithRef:(_Nonnull id)ref;
- (void)onError:(int32_t)errCode errMsg:(NSString* _Nullable)errMsg;
- (void)onProgress:(long)progress;
- (void)onSuccess:(NSString* _Nullable)data;
@end
#endif

View File

@@ -1,6 +1,7 @@
framework module "OpenIMCore" { framework module "OpenIMCore" {
header "ref.h" header "ref.h"
header "Open_im_sdk.objc.h" header "Open_im_sdk.objc.h"
header "Open_im_sdk_callback.objc.h"
header "Universe.objc.h" header "Universe.objc.h"
header "OpenIMCore.h" header "OpenIMCore.h"

View File

@@ -1,23 +1,24 @@
library flutter_openim_sdk; library flutter_openim_sdk;
export 'src/enum/conversation_type.dart'; export 'src/enum/conversation_type.dart';
export 'src/enum/group_role.dart'; export 'src/enum/group_role_level.dart';
export 'src/enum/im_platform.dart'; export 'src/enum/im_platform.dart';
export 'src/enum/listener_type.dart'; export 'src/enum/listener_type.dart';
export 'src/enum/message_status.dart'; export 'src/enum/message_status.dart';
export 'src/enum/message_type.dart'; export 'src/enum/message_type.dart';
export 'src/listener/advanced_msg_listener.dart'; export 'src/listener/advanced_msg_listener.dart';
export 'src/listener/advanced_msg_listener.dart';
export 'src/listener/connect_listener.dart';
export 'src/listener/connect_listener.dart';
export 'src/listener/conversation_listener.dart'; export 'src/listener/conversation_listener.dart';
export 'src/listener/friendship_listener.dart'; export 'src/listener/friendship_listener.dart';
export 'src/listener/friendship_listener.dart';
export 'src/listener/group_listener.dart';
export 'src/listener/group_listener.dart'; export 'src/listener/group_listener.dart';
export 'src/listener/impl/advanced_msg_listener.dart';
export 'src/listener/impl/conversation_listener.dart';
export 'src/listener/impl/friendship_listener.dart';
export 'src/listener/impl/group_listener.dart';
export 'src/listener/impl/init_sdk_listener.dart';
export 'src/listener/impl/msg_send_progress_listener.dart';
export 'src/listener/init_sdk_listener.dart';
export 'src/listener/msg_send_progress_listener.dart'; export 'src/listener/msg_send_progress_listener.dart';
export 'src/listener/msg_send_progress_listener.dart';
export 'src/listener/user_listener.dart';
export 'src/listener/user_listener.dart';
export 'src/manager/im_conversation_manager.dart'; export 'src/manager/im_conversation_manager.dart';
export 'src/manager/im_friendship_manager.dart'; export 'src/manager/im_friendship_manager.dart';
export 'src/manager/im_group_manager.dart'; export 'src/manager/im_group_manager.dart';
@@ -25,9 +26,10 @@ export 'src/manager/im_manager.dart';
export 'src/manager/im_message_manager.dart'; export 'src/manager/im_message_manager.dart';
export 'src/manager/im_offline_push_manager.dart'; export 'src/manager/im_offline_push_manager.dart';
export 'src/manager/im_signaling_manager.dart'; export 'src/manager/im_signaling_manager.dart';
export 'src/manager/v2/im_message_manager_v2.dart'; export 'src/manager/im_user_manager.dart';
export 'src/models/conversation_info.dart'; export 'src/models/conversation_info.dart';
export 'src/models/group_info.dart'; export 'src/models/group_info.dart';
export 'src/models/message.dart'; export 'src/models/message.dart';
export 'src/models/user_info.dart'; export 'src/models/user_info.dart';
export 'src/openim.dart'; export 'src/openim.dart';
export 'src/utils.dart';

View File

@@ -1,4 +1,4 @@
class ConversationType { class ConversationType {
static const single_chat = 1; static const single = 1;
static const group_chat = 2; static const group = 2;
} }

View File

@@ -1,5 +0,0 @@
class GroupRole {
static const member = 0;
static const owner = 1;
static const admin = 2;
}

View File

@@ -0,0 +1,7 @@
/// 1 ordinary member, 2 group owners, 3 administrators
/// 1普通成员, 2群主3管理员
class GroupRoleLevel {
static const member = 1;
static const owner = 2;
static const admin = 3;
}

View File

@@ -1,10 +1,11 @@
class ListenerType { class ListenerType {
static const simpleMsgListener = 'simpleMsgListener'; static final simpleMsgListener = 'simpleMsgListener';
static const initSDKListener = 'initSDKListener'; static final connectListener = 'connectListener';
static const groupListener = 'groupListener'; static final userListener = 'userListener';
static const advancedMsgListener = 'advancedMsgListener'; static final groupListener = 'groupListener';
static const conversationListener = 'conversationListener'; static final advancedMsgListener = 'advancedMsgListener';
static const friendListener = 'friendListener'; static final conversationListener = 'conversationListener';
static const signalingListener = 'signalingListener'; static final friendListener = 'friendListener';
static const msgSendProgressListener = "msgSendProgressListener"; static final signalingListener = 'signalingListener';
static final msgSendProgressListener = "msgSendProgressListener";
} }

View File

@@ -1,17 +1,33 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
abstract class AdvancedMsgListener { class OnAdvancedMsgListener {
/// Uniquely identifies /// Message read receipt
final String id; Function(List<ReadReceiptInfo> list)? onRecvC2CReadReceipt;
AdvancedMsgListener() : id = "id_${DateTime.now().microsecondsSinceEpoch}"; /// A friend revoked a message
Function(String msgId)? onRecvMessageRevoked;
/// Receive new message /// Receive new message
void recvNewMessage(Message msg); Function(Message msg)? onRecvNewMessage;
/// Message read receipt /// Uniquely identifies
void recvC2CReadReceipt(List<HaveReadInfo> list); String id;
/// A friend withdrew a message OnAdvancedMsgListener({
void recvMessageRevoked(String msgId); this.onRecvC2CReadReceipt,
this.onRecvMessageRevoked,
this.onRecvNewMessage,
}) : id = "id_${DateTime.now().microsecondsSinceEpoch}";
void recvC2CReadReceipt(List<ReadReceiptInfo> list) {
if (null != onRecvC2CReadReceipt) onRecvC2CReadReceipt!(list);
}
void recvMessageRevoked(String msgId) {
if (null != onRecvMessageRevoked) onRecvMessageRevoked!(msgId);
}
void recvNewMessage(Message msg) {
if (null != onRecvNewMessage) onRecvNewMessage!(msg);
}
} }

View File

@@ -1,48 +1,45 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; class OnConnectListener {
/// SDK failed to connect to the server
class OnInitSDKListener extends InitSDKListener {
Function(int? code, String? errorMsg)? onConnectFailed; Function(int? code, String? errorMsg)? onConnectFailed;
/// SDK has successfully connected to the server
Function()? onConnectSuccess; Function()? onConnectSuccess;
/// SDK is connecting to the server
Function()? onConnecting; Function()? onConnecting;
/// The current user is kicked offline.
/// At this time, the UI can prompt the user and call IMManager's login() function to log in again.
Function()? onKickedOffline; Function()? onKickedOffline;
Function(UserInfo info)? onSelfInfoUpdated;
/// Ticket expired when online.
/// At this time, you need to generate a new userSig and call IMManager's login() function to log in again
Function()? onUserSigExpired; Function()? onUserSigExpired;
OnInitSDKListener({ OnConnectListener({
this.onConnectFailed, this.onConnectFailed,
this.onConnectSuccess, this.onConnectSuccess,
this.onConnecting, this.onConnecting,
this.onKickedOffline, this.onKickedOffline,
this.onSelfInfoUpdated,
this.onUserSigExpired, this.onUserSigExpired,
}); });
@override
void connectFailed(int? code, String? errorMsg) { void connectFailed(int? code, String? errorMsg) {
if (null != onConnectFailed) onConnectFailed!(code, errorMsg); if (null != onConnectFailed) onConnectFailed!(code, errorMsg);
} }
@override
void connectSuccess() { void connectSuccess() {
if (null != onConnectSuccess) onConnectSuccess!(); if (null != onConnectSuccess) onConnectSuccess!();
} }
@override
void connecting() { void connecting() {
if (null != onConnecting) onConnecting!.call(); if (null != onConnecting) onConnecting!.call();
} }
@override
void kickedOffline() { void kickedOffline() {
if (null != onKickedOffline) onKickedOffline!(); if (null != onKickedOffline) onKickedOffline!();
} }
@override
void selfInfoUpdated(UserInfo info) {
if (null != onSelfInfoUpdated) onSelfInfoUpdated!(info);
}
@override
void userSigExpired() { void userSigExpired() {
if (null != onUserSigExpired) onUserSigExpired!(); if (null != onUserSigExpired) onUserSigExpired!();
} }

View File

@@ -1,15 +1,44 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
abstract class ConversationListener { class OnConversationListener {
void conversationChanged(List<ConversationInfo> list); Function(List<ConversationInfo> list)? onConversationChanged;
Function(List<ConversationInfo> list)? onNewConversation;
Function(int count)? onTotalUnreadMessageCountChanged;
Function()? onSyncServerFailed;
Function()? onSyncServerFinish;
Function()? onSyncServerStart;
void newConversation(List<ConversationInfo> list); OnConversationListener({
this.onConversationChanged,
this.onNewConversation,
this.onTotalUnreadMessageCountChanged,
this.onSyncServerFailed,
this.onSyncServerFinish,
this.onSyncServerStart,
});
void syncServerFailed(); void conversationChanged(List<ConversationInfo> list) {
if (onConversationChanged != null) onConversationChanged!(list);
}
void syncServerFinish(); void newConversation(List<ConversationInfo> list) {
if (onNewConversation != null) onNewConversation!(list);
}
void syncServerStart(); void syncServerFailed() {
if (onSyncServerFailed != null) onSyncServerFailed!();
}
void totalUnreadMessageCountChanged(int i); void syncServerFinish() {
if (onSyncServerFinish != null) onSyncServerFinish!();
}
void syncServerStart() {
if (onSyncServerStart != null) onSyncServerStart!();
}
void totalUnreadMessageCountChanged(int i) {
if (onTotalUnreadMessageCountChanged != null)
onTotalUnreadMessageCountChanged!(i);
}
} }

View File

@@ -1,21 +1,61 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
abstract class FriendshipListener { class OnFriendshipListener {
void blackListAdd(UserInfo u); Function(FriendApplicationInfo i)? onFriendApplicationAdded;
Function(FriendApplicationInfo i)? onFriendApplicationDeleted;
Function(FriendApplicationInfo i)? onFriendApplicationAccepted;
Function(FriendApplicationInfo i)? onFriendApplicationRejected;
Function(FriendInfo i)? onFriendAdded;
Function(FriendInfo i)? onFriendDeleted;
Function(FriendInfo i)? onFriendInfoChanged;
Function(BlacklistInfo i)? onBlacklistAdded;
Function(BlacklistInfo i)? onBlacklistDeleted;
void blackListDeleted(UserInfo u); OnFriendshipListener({
this.onBlacklistAdded,
this.onBlacklistDeleted,
this.onFriendAdded,
this.onFriendApplicationAccepted,
this.onFriendApplicationAdded,
this.onFriendApplicationDeleted,
this.onFriendApplicationRejected,
this.onFriendDeleted,
this.onFriendInfoChanged,
});
void friendApplicationListAccept(UserInfo u); void blacklistAdded(BlacklistInfo u) {
onBlacklistAdded?.call(u);
}
void friendApplicationListAdded(UserInfo u); void blacklistDeleted(BlacklistInfo u) {
onBlacklistDeleted?.call(u);
}
void friendApplicationListDeleted(UserInfo u); void friendAdded(FriendInfo u) {
onFriendAdded?.call(u);
}
void friendApplicationListReject(UserInfo u); void friendApplicationAccepted(FriendApplicationInfo u) {
onFriendApplicationAccepted?.call(u);
}
void friendInfoChanged(UserInfo u); void friendApplicationAdded(FriendApplicationInfo u) {
onFriendApplicationAdded?.call(u);
}
void friendListAdded(UserInfo u); void friendApplicationDeleted(FriendApplicationInfo u) {
onFriendApplicationDeleted?.call(u);
}
void friendListDeleted(UserInfo u); void friendApplicationRejected(FriendApplicationInfo u) {
onFriendApplicationRejected?.call(u);
}
void friendDeleted(FriendInfo u) {
onFriendDeleted?.call(u);
}
void friendInfoChanged(FriendInfo u) {
onFriendInfoChanged?.call(u);
}
} }

View File

@@ -1,23 +1,67 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
abstract class GroupListener { class OnGroupListener {
void memberEnter(String groupId, List<GroupMembersInfo> list); Function(GroupApplicationInfo info)? onGroupApplicationAccepted;
Function(GroupApplicationInfo info)? onGroupApplicationAdded;
Function(GroupApplicationInfo info)? onGroupApplicationDeleted;
Function(GroupApplicationInfo info)? onGroupApplicationRejected;
Function(GroupInfo info)? onGroupInfoChanged;
Function(GroupMembersInfo info)? onGroupMemberAdded;
Function(GroupMembersInfo info)? onGroupMemberDeleted;
Function(GroupMembersInfo info)? onGroupMemberInfoChanged;
Function(GroupInfo info)? onJoinedGroupAdded;
Function(GroupInfo info)? onJoinedGroupDeleted;
void memberLeave(String groupId, GroupMembersInfo info); OnGroupListener({
this.onGroupApplicationAccepted,
this.onGroupApplicationAdded,
this.onGroupApplicationDeleted,
this.onGroupApplicationRejected,
this.onGroupInfoChanged,
this.onGroupMemberAdded,
this.onGroupMemberDeleted,
this.onGroupMemberInfoChanged,
this.onJoinedGroupAdded,
this.onJoinedGroupDeleted,
});
void memberInvited( void groupApplicationAccepted(GroupApplicationInfo info) {
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list); onGroupApplicationAccepted?.call(info);
}
void memberKicked( void groupApplicationAdded(GroupApplicationInfo info) {
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list); onGroupApplicationAdded?.call(info);
}
void groupCreated(String groupId); void groupApplicationDeleted(GroupApplicationInfo info) {
onGroupApplicationDeleted?.call(info);
}
void groupInfoChanged(String groupId, GroupInfo info); void groupApplicationRejected(GroupApplicationInfo info) {
onGroupApplicationRejected?.call(info);
}
void receiveJoinApplication( void groupInfoChanged(GroupInfo info) {
String groupId, GroupMembersInfo info, String opReason); onGroupInfoChanged?.call(info);
}
void applicationProcessed(String groupId, GroupMembersInfo opUser, void groupMemberAdded(GroupMembersInfo info) {
int agreeOrReject, String opReason); onGroupMemberAdded?.call(info);
}
void groupMemberDeleted(GroupMembersInfo info) {
onGroupMemberDeleted?.call(info);
}
void groupMemberInfoChanged(GroupMembersInfo info) {
onGroupMemberInfoChanged?.call(info);
}
void joinedGroupAdded(GroupInfo info) {
onJoinedGroupAdded?.call(info);
}
void joinedGroupDeleted(GroupInfo info) {
onJoinedGroupDeleted?.call(info);
}
} }

View File

@@ -1,28 +0,0 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class OnAdvancedMsgListener extends AdvancedMsgListener {
Function(List<HaveReadInfo> list)? onRecvC2CReadReceipt;
Function(String msgId)? onRecvMessageRevoked;
Function(Message msg)? onRecvNewMessage;
OnAdvancedMsgListener({
this.onRecvC2CReadReceipt,
this.onRecvMessageRevoked,
this.onRecvNewMessage,
});
@override
void recvC2CReadReceipt(List<HaveReadInfo> list) {
if (null != onRecvC2CReadReceipt) onRecvC2CReadReceipt!(list);
}
@override
void recvMessageRevoked(String msgId) {
if (null != onRecvMessageRevoked) onRecvMessageRevoked!(msgId);
}
@override
void recvNewMessage(Message msg) {
if (null != onRecvNewMessage) onRecvNewMessage!(msg);
}
}

View File

@@ -1,50 +0,0 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class OnConversationListener extends ConversationListener {
Function(List<ConversationInfo> list)? onConversationChanged;
Function(List<ConversationInfo> list)? onNewConversation;
Function(int count)? onTotalUnreadMessageCountChanged;
Function()? onSyncServerFailed;
Function()? onSyncServerFinish;
Function()? onSyncServerStart;
OnConversationListener({
this.onConversationChanged,
this.onNewConversation,
this.onTotalUnreadMessageCountChanged,
this.onSyncServerFailed,
this.onSyncServerFinish,
this.onSyncServerStart,
});
@override
void conversationChanged(List<ConversationInfo> list) {
if (onConversationChanged != null) onConversationChanged!(list);
}
@override
void newConversation(List<ConversationInfo> list) {
if (onNewConversation != null) onNewConversation!(list);
}
@override
void syncServerFailed() {
if (onSyncServerFailed != null) onSyncServerFailed!();
}
@override
void syncServerFinish() {
if (onSyncServerFinish != null) onSyncServerFinish!();
}
@override
void syncServerStart() {
if (onSyncServerStart != null) onSyncServerStart!();
}
@override
void totalUnreadMessageCountChanged(int i) {
if (onTotalUnreadMessageCountChanged != null)
onTotalUnreadMessageCountChanged!(i);
}
}

View File

@@ -1,73 +0,0 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class OnFriendshipListener extends FriendshipListener {
Function(UserInfo u)? onBlackListAdd;
Function(UserInfo u)? onBlackListDeleted;
Function(UserInfo u)? onFriendApplicationListAccept;
Function(UserInfo u)? onFriendApplicationListAdded;
Function(UserInfo u)? onFriendApplicationListDeleted;
Function(UserInfo u)? onFriendApplicationListReject;
Function(UserInfo u)? onFriendInfoChanged;
Function(UserInfo u)? onFriendListAdded;
Function(UserInfo u)? onFriendListDeleted;
OnFriendshipListener({
this.onBlackListAdd,
this.onBlackListDeleted,
this.onFriendApplicationListAccept,
this.onFriendApplicationListAdded,
this.onFriendApplicationListDeleted,
this.onFriendApplicationListReject,
this.onFriendInfoChanged,
this.onFriendListAdded,
this.onFriendListDeleted,
});
@override
void blackListAdd(UserInfo u) {
if (null != onBlackListAdd) onBlackListAdd!(u);
}
@override
void blackListDeleted(UserInfo u) {
if (null != onBlackListDeleted) onBlackListDeleted!(u);
}
@override
void friendApplicationListAccept(UserInfo u) {
if (null != onFriendApplicationListAccept)
onFriendApplicationListAccept!(u);
}
@override
void friendApplicationListAdded(UserInfo u) {
if (null != onFriendApplicationListAdded) onFriendApplicationListAdded!(u);
}
@override
void friendApplicationListDeleted(UserInfo u) {
if (null != onFriendApplicationListDeleted)
onFriendApplicationListDeleted!(u);
}
@override
void friendApplicationListReject(UserInfo u) {
if (null != onFriendApplicationListReject)
onFriendApplicationListReject!(u);
}
@override
void friendInfoChanged(UserInfo u) {
if (null != onFriendInfoChanged) onFriendInfoChanged!(u);
}
@override
void friendListAdded(UserInfo u) {
if (null != onFriendListAdded) onFriendListAdded!(u);
}
@override
void friendListDeleted(UserInfo u) {
if (null != onFriendListDeleted) onFriendListDeleted!(u);
}
}

View File

@@ -1,75 +0,0 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class OnGroupListener extends GroupListener {
Function(String groupId, GroupMembersInfo opUser, int agreeOrReject,
String opReason)? onApplicationProcessed;
Function(String groupId)? onGroupCreated;
Function(String groupId, GroupInfo info)? onGroupInfoChanged;
Function(String groupId, List<GroupMembersInfo> list)? onMemberEnter;
Function(
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list)?
onMemberInvited;
Function(
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list)?
onMemberKicked;
Function(String groupId, GroupMembersInfo info)? onMemberLeave;
Function(String groupId, GroupMembersInfo info, String opReason)?
onReceiveJoinApplication;
OnGroupListener({
this.onApplicationProcessed,
this.onGroupCreated,
this.onGroupInfoChanged,
this.onMemberEnter,
this.onMemberInvited,
this.onMemberKicked,
this.onMemberLeave,
this.onReceiveJoinApplication,
});
@override
void applicationProcessed(String groupId, GroupMembersInfo opUser,
int agreeOrReject, String opReason) {
if (null != onApplicationProcessed)
onApplicationProcessed!(groupId, opUser, agreeOrReject, opReason);
}
@override
void groupCreated(String groupId) {
if (null != onGroupCreated) onGroupCreated!(groupId);
}
@override
void groupInfoChanged(String groupId, GroupInfo info) {
if (null != onGroupInfoChanged) onGroupInfoChanged!(groupId, info);
}
@override
void memberEnter(String groupId, List<GroupMembersInfo> list) {
if (null != onMemberEnter) onMemberEnter!(groupId, list);
}
@override
void memberInvited(
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list) {
if (null != onMemberInvited) onMemberInvited!(groupId, opUser, list);
}
@override
void memberKicked(
String groupId, GroupMembersInfo opUser, List<GroupMembersInfo> list) {
if (null != onMemberKicked) onMemberKicked!(groupId, opUser, list);
}
@override
void memberLeave(String groupId, GroupMembersInfo info) {
if (null != onMemberLeave) onMemberLeave!(groupId, info);
}
@override
void receiveJoinApplication(
String groupId, GroupMembersInfo info, String opReason) {
if (null != onReceiveJoinApplication)
onReceiveJoinApplication!(groupId, info, opReason);
}
}

View File

@@ -1,11 +0,0 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class OnMsgSendProgressListener extends MsgSendProgressListener {
Function(String msgID, int progress)? onProgress;
OnMsgSendProgressListener({this.onProgress});
void progress(String msgID, int progress) {
if (null != onProgress) onProgress!(msgID, progress);
}
}

View File

@@ -1,23 +0,0 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
abstract class InitSDKListener {
/// SDK is connecting to the server
void connecting();
/// SDK has successfully connected to the server
void connectSuccess();
/// SDK failed to connect to the server
void connectFailed(int? code, String? errorMsg);
/// The current user is kicked offline.
/// At this time, the UI can prompt the user and call IMManager's login() function to log in again.
void kickedOffline();
/// Ticket expired when online.
/// At this time, you need to generate a new userSig and call IMManager's login() function to log in again
void userSigExpired();
/// The information of the logged-in user has been updated
void selfInfoUpdated(UserInfo info);
}

View File

@@ -1,3 +1,9 @@
abstract class MsgSendProgressListener { class OnMsgSendProgressListener {
void progress(String msgID, int progress); Function(String clientMsgID, int progress)? onProgress;
OnMsgSendProgressListener({this.onProgress});
void progress(String clientMsgID, int progress) {
if (null != onProgress) onProgress!(clientMsgID, progress);
}
} }

View File

@@ -0,0 +1,12 @@
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class OnUserListener {
/// The information of the logged-in user has been updated
Function(UserInfo info)? onSelfInfoUpdated;
OnUserListener({this.onSelfInfoUpdated});
void selfInfoUpdated(UserInfo info) {
onSelfInfoUpdated?.call(info);
}
}

View File

@@ -1,33 +1,60 @@
import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
///
///
class ConversationManager { class ConversationManager {
MethodChannel _channel; MethodChannel _channel;
late ConversationListener conversationListener; late OnConversationListener conversationListener;
ConversationManager(this._channel); ConversationManager(this._channel);
/// Observe conversation changes /// Observe conversation changes
Future setConversationListener(ConversationListener listener) { /// 会话监听
Future setConversationListener(OnConversationListener listener) {
this.conversationListener = listener; this.conversationListener = listener;
return _channel.invokeMethod('setConversationListener', _buildParam({})); return _channel.invokeMethod('setConversationListener', _buildParam({}));
} }
/// Get all conversations /// Get all conversations
Future<List<ConversationInfo>> getAllConversationList() => _channel /// 获取所有会话
.invokeMethod('getAllConversationList', _buildParam({})) Future<List<ConversationInfo>> getAllConversationList(
.then((value) => _toList(value)); {String? operationID}) =>
_channel
.invokeMethod(
'getAllConversationList',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
/// Get a single conversation info /// Paging to get conversation
/// 分页获取会话
Future<List<ConversationInfo>> getConversationListSplit({
int offset = 0,
int count = 20,
String? operationID,
}) =>
_channel
.invokeMethod(
'getConversationListSplit',
_buildParam({
'offset': offset,
'count': count,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
/// Get a conversation, if it doesn't exist it will be created automatically
/// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID /// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
/// [sessionType] if it is a single chat, it value is 1. if it is a group chat, it value is 2 /// [sessionType] if it is a single chat, it value is 1. if it is a group chat, it value is 2
Future<ConversationInfo> getSingleConversation({ /// 获取一个会话,如果不存在会自动创建
/// [sourceID] 如果是单聊值传用户ID如果是群聊值传组ID
/// [sessionType] 如果是单聊值传1如果是群聊值传2
Future<ConversationInfo> getOneConversation({
required String sourceID, required String sourceID,
required int sessionType, required int sessionType,
String? operationID,
}) => }) =>
_channel _channel
.invokeMethod( .invokeMethod(
@@ -35,112 +62,176 @@ class ConversationManager {
_buildParam({ _buildParam({
"sourceID": sourceID, "sourceID": sourceID,
"sessionType": sessionType, "sessionType": sessionType,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) =>
Utils.toObj(value, (map) => ConversationInfo.fromJson(map)));
/// Get conversation list by id list /// Get conversation list by id list
/// 获取多个会话
Future<List<ConversationInfo>> getMultipleConversation({ Future<List<ConversationInfo>> getMultipleConversation({
required List<String> conversationIDList, required List<String> conversationIDList,
String? operationID,
}) => }) =>
_channel _channel
.invokeMethod( .invokeMethod(
'getMultipleConversation', 'getMultipleConversation',
_buildParam({ _buildParam({
"conversationIDList": conversationIDList, "conversationIDList": conversationIDList,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toList(value)); .then((value) =>
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
/// Delete conversation by id /// Delete conversation by id
/// 删除会话
Future deleteConversation({ Future deleteConversation({
required String conversationID, required String conversationID,
String? operationID,
}) => }) =>
_channel _channel.invokeMethod(
.invokeMethod(
'deleteConversation', 'deleteConversation',
_buildParam({ _buildParam({
"conversationID": conversationID, "conversationID": conversationID,
})) "operationID": Utils.checkOperationID(operationID),
.then((value) => _printValue(value)); }));
/// Set draft /// Set draft
/// 设置会话草稿
Future setConversationDraft({ Future setConversationDraft({
required String conversationID, required String conversationID,
required String draftText, required String draftText,
String? operationID,
}) => }) =>
_channel _channel.invokeMethod(
.invokeMethod(
'setConversationDraft', 'setConversationDraft',
_buildParam({ _buildParam({
"conversationID": conversationID, "conversationID": conversationID,
"draftText": draftText, "draftText": draftText,
})) "operationID": Utils.checkOperationID(operationID),
.then((value) => _printValue(value)); }));
/// Pinned conversation /// Pinned conversation
/// 置顶会话
Future pinConversation({ Future pinConversation({
required String conversationID, required String conversationID,
required bool isPinned, required bool isPinned,
String? operationID,
}) => }) =>
_channel _channel.invokeMethod(
.invokeMethod(
'pinConversation', 'pinConversation',
_buildParam({ _buildParam({
"conversationID": conversationID, "conversationID": conversationID,
"isPinned": isPinned, "isPinned": isPinned,
})) "operationID": Utils.checkOperationID(operationID),
.then((value) => _printValue(value)); }));
/// Mark single chat messages as read // Future<dynamic> markSingleMessageHasRead({required String userID}) =>
Future<dynamic> markSingleMessageHasRead({required String userID}) { // _channel.invokeMethod(
return _channel.invokeMethod( // 'markSingleMessageHasRead', _buildParam({'userID': userID}));
'markSingleMessageHasRead', _buildParam({'userID': userID}));
}
/// Mark group chat messages as read /// Mark group chat messages as read
Future<dynamic> markGroupMessageHasRead({required String groupID}) { /// 标记群聊已读
return _channel.invokeMethod( Future<dynamic> markGroupMessageHasRead({
'markGroupMessageHasRead', _buildParam({'groupID': groupID})); required String groupID,
} String? operationID,
}) =>
_channel.invokeMethod(
'markGroupMessageHasRead',
_buildParam({
'groupID': groupID,
"operationID": Utils.checkOperationID(operationID),
}));
/// Get the total number of unread messages /// Get the total number of unread messages
Future<dynamic> getTotalUnreadMsgCount() { /// 获取未读消息总数
return _channel.invokeMethod('getTotalUnreadMsgCount', _buildParam({})); Future<dynamic> getTotalUnreadMsgCount({
} String? operationID,
}) =>
_channel.invokeMethod(
'getTotalUnreadMsgCount',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}));
/// Query conversation id /// Query conversation id
/// [sourceID] : if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID /// [sourceID] if it is a single chat, Its value is userID. if it is a group chat, Its value is groupID
/// [sessionType] : if it is a single chat, it value is 1. if it is a group chat, it value is 2 /// [sessionType] if it is a single chat, it value is 1. if it is a group chat, it value is 2
Future<dynamic> getConversationID({ /// 查询会话id
/// [sourceID] 如果是单聊值传用户ID如果是群聊值传组ID
/// [sessionType] 如果是单聊值传1如果是群聊值传2
Future<dynamic> getConversationIDBySessionType({
required String sourceID, required String sourceID,
required int sessionType, required int sessionType,
}) { }) =>
return _channel.invokeMethod( _channel.invokeMethod(
'getConversationIDBySessionType', 'getConversationIDBySessionType',
_buildParam({ _buildParam({
"sourceID": sourceID, "sourceID": sourceID,
"sessionType": sessionType, "sessionType": sessionType,
})); }));
/// Message Do Not Disturb
/// [status] 0: Normal. 1: Do not receive messages. 2: Do not notify when messages are received.
/// 消息免打扰设置
/// [status] 0正常1不接受消息2接受在线消息不接受离线消息
Future<dynamic> setConversationRecvMessageOpt({
required List<String> conversationIDList,
required int status,
String? operationID,
}) =>
_channel.invokeMethod(
'setConversationRecvMessageOpt',
_buildParam({
"conversationIDList": conversationIDList,
"status": status,
"operationID": Utils.checkOperationID(operationID),
}));
/// Message Do Not Disturb
/// [{"conversationId":"single_13922222222","result":0}]
/// 查询免打扰状态
Future<List<dynamic>> getConversationRecvMessageOpt({
required List<String> conversationIDList,
String? operationID,
}) =>
_channel
.invokeMethod(
'getConversationRecvMessageOpt',
_buildParam({
"conversationIDList": conversationIDList,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toListMap(value));
/// Custom sort for conversation list
/// 会话列表自定义排序规则。
List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list
..sort((a, b) {
if ((a.isPinned == true && b.isPinned == true) ||
(a.isPinned != true && b.isPinned != true)) {
int aCompare = a.draftTextTime! > a.latestMsgSendTime!
? a.draftTextTime!
: a.latestMsgSendTime!;
int bCompare = b.draftTextTime! > b.latestMsgSendTime!
? b.draftTextTime!
: b.latestMsgSendTime!;
if (aCompare > bCompare) {
return -1;
} else if (aCompare < bCompare) {
return 1;
} else {
return 0;
} }
} else if (a.isPinned == true && b.isPinned != true) {
return -1;
} else {
return 1;
}
});
static Map _buildParam(Map param) { static Map _buildParam(Map param) {
param["ManagerName"] = "conversationManager"; param["ManagerName"] = "conversationManager";
return param; return param;
} }
static List<ConversationInfo> _toList(String? value) {
var list = _formatJson(value);
if (null == list) return <ConversationInfo>[];
return (list as List).map((e) => ConversationInfo.fromJson(e)).toList();
}
static ConversationInfo _toObj(String value) =>
ConversationInfo.fromJson(_formatJson(value));
static dynamic _formatJson(value) {
return jsonDecode(_printValue(value));
}
static String _printValue(value) {
return value;
}
} }

View File

@@ -1,146 +1,207 @@
import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class FriendshipManager { class FriendshipManager {
MethodChannel _channel; MethodChannel _channel;
late FriendshipListener friendshipListener; late OnFriendshipListener friendshipListener;
FriendshipManager(this._channel); FriendshipManager(this._channel);
/// Set up a friend relationship listener /// Set up a friend relationship listener
Future setFriendshipListener(FriendshipListener listener) { /// 好友关系监听
Future setFriendshipListener(OnFriendshipListener listener) {
this.friendshipListener = listener; this.friendshipListener = listener;
return _channel.invokeMethod('setFriendListener', _buildParam({})); return _channel.invokeMethod('setFriendListener', _buildParam({}));
} }
/// Get friend info by user id /// Get friend info by user id
Future<List<UserInfo>> getFriendsInfo({required List<String> uidList}) { /// 查询好友信息
return _channel Future<List<UserInfo>> getFriendsInfo({
.invokeMethod('getFriendsInfo', _buildParam({"uidList": uidList})) required List<String> uidList,
.then((value) => _toList(value)); String? operationID,
} }) =>
_channel
.invokeMethod(
'getFriendsInfo',
_buildParam({
"uidList": uidList,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
/// Send an friend application /// Send an friend application
Future<dynamic> addFriend({required String uid, required String reason}) { /// 发送一个好友请求
return _channel.invokeMethod( Future<dynamic> addFriend({
'addFriend', _buildParam({"uid": uid, "reqMessage": reason})); required String uid,
} String? reason,
String? operationID,
/// Get all friend application, sent to you by others }) =>
Future<List<UserInfo>> getFriendApplicationList() { _channel.invokeMethod(
return _channel 'addFriend',
.invokeMethod('getFriendApplicationList', _buildParam({}))
.then((value) => _toList(value));
}
/// Find all friends including those who have been added to the blacklist
Future<List<UserInfo>> getFriendList() {
return _channel
.invokeMethod('getFriendList', _buildParam({}))
.then((value) => _toList(value));
}
/// Find all friends including those who have been added to the blacklist
Future<List<dynamic>> getFriendListMap() {
return _channel
.invokeMethod('getFriendList', _buildParam({}))
.then((value) => _toListMap(value));
}
/// Modify friend information, only [comment] can be modified
Future<dynamic> setFriendInfo(
{required String uid, required String comment}) {
return _channel.invokeMethod(
'setFriendInfo',
_buildParam({ _buildParam({
'uid': uid, "toUserID": uid,
'comment': comment, "reqMsg": reason,
"operationID": Utils.checkOperationID(operationID),
}));
/// Get someone's request to add me as a friend
/// 获取别人加我为好友的申请
Future<List<FriendApplicationInfo>> getRecvFriendApplicationList(
{String? operationID}) =>
_channel
.invokeMethod(
'getRecvFriendApplicationList',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (v) => FriendApplicationInfo.fromJson(v)));
/// Get friend requests from me
/// 获取我发出的好友申请
Future<List<FriendApplicationInfo>> getSendFriendApplicationList(
{String? operationID}) =>
_channel
.invokeMethod(
'getSendFriendApplicationList',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (v) => FriendApplicationInfo.fromJson(v)));
/// Find all friends including those who have been added to the blacklist
/// 获取好友列表包含已拉入黑名单的好友
Future<List<UserInfo>> getFriendList({String? operationID}) => _channel
.invokeMethod(
'getFriendList',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
/// Find all friends including those who have been added to the blacklist
/// 获取好友列表
Future<List<dynamic>> getFriendListMap({String? operationID}) => _channel
.invokeMethod(
'getFriendList',
_buildParam({
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toListMap(value));
/// Modify friend remark name
/// 设置好友备注
Future<dynamic> setFriendRemark({
required String uid,
required String remark,
String? operationID,
}) =>
_channel.invokeMethod(
'setFriendRemark',
_buildParam({
'toUserID': uid,
'remark': remark,
"operationID": Utils.checkOperationID(operationID),
})); }));
}
/// Add friends to blacklist /// Add friends to blacklist
Future<dynamic> addToBlackList({required String uid}) { /// 加入黑名单
return _channel.invokeMethod('addToBlackList', _buildParam({"uid": uid})); Future<dynamic> addBlacklist({
} required String uid,
String? operationID,
}) =>
_channel.invokeMethod(
'addBlacklist',
_buildParam({
"uid": uid,
"operationID": Utils.checkOperationID(operationID),
}));
/// Find all blacklist /// Find all blacklist
Future<List<UserInfo>> getBlackList() { /// 获取黑名单列表
return _channel Future<List<UserInfo>> getBlacklist({String? operationID}) => _channel
.invokeMethod('getBlackList', _buildParam({})) .invokeMethod(
.then((value) => _toList(value)); 'getBlacklist',
} _buildParam({
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
/// Remove from blacklist /// Remove from blacklist
Future<dynamic> deleteFromBlackList({required String uid}) { /// 从黑名单移除
return _channel.invokeMethod( Future<dynamic> removeBlacklist({
'deleteFromBlackList', _buildParam({"uid": uid})); required String uid,
} String? operationID,
}) =>
_channel.invokeMethod(
'removeBlacklist',
_buildParam({
"uid": uid,
"operationID": Utils.checkOperationID(operationID),
}));
/// Determine if there is a friendship by userId /// Determine if there is a friendship by userId
Future<List<UserInfo>> checkFriend(List<String> uidList) { /// 检查友好关系
return _channel Future<List<FriendshipInfo>> checkFriend({
.invokeMethod('checkFriend', _buildParam({'uidList': uidList})) required List<String> uidList,
.then((value) => _toList(value)); String? operationID,
} }) =>
_channel
.invokeMethod(
'checkFriend',
_buildParam({
'uidList': uidList,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (v) => FriendshipInfo.fromJson(v)));
/// Dissolve friendship from friend list /// Dissolve friendship from friend list
Future<dynamic> deleteFromFriendList({required String uid}) { /// 删除好友
return _channel.invokeMethod( Future<dynamic> deleteFriend({
'deleteFromFriendList', _buildParam({"uid": uid})); required String uid,
} String? operationID,
}) =>
_channel.invokeMethod(
'deleteFriend',
_buildParam({
"uid": uid,
"operationID": Utils.checkOperationID(operationID),
}));
/// Accept application of be friend /// Accept application of be friend
Future<dynamic> acceptFriendApplication({required String uid}) { /// 接受好友请求
return _channel.invokeMethod( Future<dynamic> acceptFriendApplication({
'acceptFriendApplication', _buildParam({"uid": uid})); required String uid,
} String? handleMsg,
String? operationID,
}) =>
_channel.invokeMethod(
'acceptFriendApplication',
_buildParam({
"toUserID": uid,
"handleMsg": handleMsg,
"operationID": Utils.checkOperationID(operationID),
}));
/// Refuse application of be friend /// Refuse application of be friend
Future<dynamic> refuseFriendApplication({required String uid}) { /// 拒绝好友请求
return _channel.invokeMethod( Future<dynamic> refuseFriendApplication({
'refuseFriendApplication', _buildParam({"uid": uid})); required String uid,
} String? handleMsg,
String? operationID,
/// }) =>
// Future<dynamic> forceSyncFriendApplication() { _channel.invokeMethod(
// return _channel.invokeMethod('forceSyncFriendApplication', _buildParam({})); 'refuseFriendApplication',
// } _buildParam({
"toUserID": uid,
/// "handleMsg": handleMsg,
// Future<dynamic> forceSyncFriend() { "operationID": Utils.checkOperationID(operationID),
// return _channel.invokeMethod('forceSyncFriend', _buildParam({})); }));
// }
///
// Future<dynamic> forceSyncBlackList() {
// return _channel.invokeMethod('forceSyncBlackList', _buildParam({}));
// }
static Map _buildParam(Map param) { static Map _buildParam(Map param) {
param["ManagerName"] = "friendshipManager"; param["ManagerName"] = "friendshipManager";
return param; return param;
} }
static List<UserInfo> _toList(String? value) {
var list = _formatJson(value);
if (null == list) return <UserInfo>[];
return (list as List).map((e) => UserInfo.fromJson(e)).toList();
}
static List<dynamic> _toListMap(String? value) {
var list = _formatJson(value);
return list;
}
// static UserInfo _toObj(String value) => UserInfo.fromJson(_formatJson(value));
static dynamic _formatJson(value) {
return jsonDecode(_printValue(value));
}
static String _printValue(value) {
return value;
}
} }

View File

@@ -1,288 +1,327 @@
import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/src/listener/group_listener.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
import 'package:flutter_openim_sdk/src/models/group_info.dart';
class GroupManager { class GroupManager {
MethodChannel _channel; MethodChannel _channel;
late GroupListener groupListener; late OnGroupListener groupListener;
GroupManager(this._channel); GroupManager(this._channel);
/// Set up group relationship monitoring /// Set up group relationship monitoring
Future setGroupListener(GroupListener listener) { /// 组关系监听
Future setGroupListener(OnGroupListener listener) {
this.groupListener = listener; this.groupListener = listener;
return _channel.invokeMethod('setGroupListener', _buildParam({})); return _channel.invokeMethod('setGroupListener', _buildParam({}));
} }
/// Invite friends into the group /// Invite friends into the group
/// 邀请进组,直接进组无需同意。
Future<List<GroupInviteResult>> inviteUserToGroup({ Future<List<GroupInviteResult>> inviteUserToGroup({
required String groupId, required String groupId,
required List<String> uidList, required List<String> uidList,
String? reason, String? reason,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'inviteUserToGroup', 'inviteUserToGroup',
_buildParam({ _buildParam({
'gid': groupId, 'gid': groupId,
'reason': reason, 'reason': reason,
'uidList': uidList, 'uidList': uidList,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => (_formatJson(value) as List) .then((value) =>
.map((e) => GroupInviteResult.fromJson(e)) Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
.toList());
}
/// Remove member from group /// Remove member from group
/// 移除组成员
Future<List<GroupInviteResult>> kickGroupMember({ Future<List<GroupInviteResult>> kickGroupMember({
required String groupId, required String groupId,
required List<String> uidList, required List<String> uidList,
String? reason, String? reason,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'kickGroupMember', 'kickGroupMember',
_buildParam({ _buildParam({
'gid': groupId, 'gid': groupId,
'reason': reason, 'reason': reason,
'uidList': uidList, 'uidList': uidList,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => (_formatJson(value) as List) .then((value) =>
.map((e) => GroupInviteResult.fromJson(e)) Utils.toList(value, (map) => GroupInviteResult.fromJson(map)));
.toList());
}
/// Get group member's info /// Get group member's info
/// 查询组成员资料
Future<List<GroupMembersInfo>> getGroupMembersInfo({ Future<List<GroupMembersInfo>> getGroupMembersInfo({
required String groupId, required String groupId,
required List<String> uidList, required List<String> uidList,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'getGroupMembersInfo', 'getGroupMembersInfo',
_buildParam({ _buildParam({
'gid': groupId, 'gid': groupId,
'uidList': uidList, 'uidList': uidList,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => (_formatJson(value) as List) .then((value) =>
.map((e) => GroupMembersInfo.fromJson(e)) Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
.toList());
}
/// Get the list of group members /// Get the list of group members
/// [filter] 0: all user, 1: group owner, 2: administrator /// 分页获取组成员列表
/// [next] begin index, pull and fill 0 for the first time Future<List<GroupMembersInfo>> getGroupMemberList({
Future<GroupMembersList> getGroupMemberList({
required String groupId, required String groupId,
int filter = 0, int filter = 0,
int next = 0, int offset = 0,
}) { int count = 0,
return _channel String? operationID,
}) =>
_channel
.invokeMethod( .invokeMethod(
'getGroupMemberList', 'getGroupMemberList',
_buildParam({ _buildParam({
'gid': groupId, 'gid': groupId,
'filter': filter, 'filter': filter,
'next': next, 'offset': offset,
'count': count,
'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => GroupMembersList.fromJson(_formatJson(value))); .then((value) =>
} Utils.toList(value, (map) => GroupMembersInfo.fromJson(map)));
/// Get the list of group members /// Get the list of group members
Future<dynamic> getGroupMemberListMap({ /// 分页获取组成员列表
Future<List<dynamic>> getGroupMemberListMap({
required String groupId, required String groupId,
int filter = 0, int filter = 0,
int next = 0, int offset = 0,
}) { int count = 0,
return _channel String? operationID,
}) =>
_channel
.invokeMethod( .invokeMethod(
'getGroupMemberList', 'getGroupMemberList',
_buildParam({ _buildParam({
'gid': groupId, 'gid': groupId,
'filter': filter, 'filter': filter,
'next': next, 'offset': offset,
'count': count,
'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => _formatJson(value)); .then((value) => Utils.toListMap(value));
}
/// Find all groups you have joined /// Find all groups you have joined
Future<List<GroupInfo>> getJoinedGroupList() { /// 查询已加入的组列表
return _channel.invokeMethod('getJoinedGroupList', _buildParam({})).then( Future<List<GroupInfo>> getJoinedGroupList({String? operationID}) => _channel
(value) => (_formatJson(value) as List) .invokeMethod(
.map((e) => GroupInfo.fromJson(e)) 'getJoinedGroupList',
.toList()); _buildParam({
} 'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
/// Find all groups you have joined /// Find all groups you have joined
Future<List<dynamic>> getJoinedGroupListMap() { /// 查询已加入的组列表
return _channel Future<List<dynamic>> getJoinedGroupListMap({String? operationID}) => _channel
.invokeMethod('getJoinedGroupList', _buildParam({})) .invokeMethod(
.then((value) => _formatJson(value)); 'getJoinedGroupList',
} _buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toListMap(value));
/// Check if you are a member of the group /// Check if you are a member of the group
Future<bool> isJoinedGroup({required String gid}) { /// 检查是否已加入组
return getJoinedGroupList() Future<bool> isJoinedGroup({
.then((list) => list.where((e) => e.groupID == gid).length > 0); required String gid,
} String? operationID,
}) =>
getJoinedGroupList(
operationID: Utils.checkOperationID(operationID),
).then((list) => list.where((e) => e.groupID == gid).length > 0);
/// Create a group /// Create a group
Future<dynamic> createGroup({ /// 创建一个组
Future<GroupInfo> createGroup({
String? groupName, String? groupName,
String? notification, String? notification,
String? introduction, String? introduction,
String? faceUrl, String? faceUrl,
int? groupType,
String? ex,
required List<GroupMemberRole> list, required List<GroupMemberRole> list,
}) { String? operationID,
return _channel.invokeMethod( }) =>
_channel
.invokeMethod(
'createGroup', 'createGroup',
_buildParam({ _buildParam({
'gInfo': { 'gInfo': {
"groupName": groupName, "groupName": groupName,
"notification": notification, "notification": notification,
"introduction": introduction, "introduction": introduction,
"faceUrl": faceUrl, "faceURL": faceUrl,
"groupType": groupType,
"ex": ex,
}, },
'memberList': list.map((e) => e.toJson()).toList() 'memberList': list.map((e) => e.toJson()).toList(),
})); 'operationID': Utils.checkOperationID(operationID),
/*.then((value) => _formatJson(value)['groupID'])*/ }))
} .then(
(value) => Utils.toObj(value, (map) => GroupInfo.fromJson(map)));
/// Edit group information /// Edit group information
/// 编辑组资料
Future<dynamic> setGroupInfo({ Future<dynamic> setGroupInfo({
required String groupID, required String groupID,
String? groupName, String? groupName,
String? notification, String? notification,
String? introduction, String? introduction,
String? faceUrl, String? faceUrl,
}) { String? ex,
return _channel.invokeMethod( String? operationID,
}) =>
_channel.invokeMethod(
'setGroupInfo', 'setGroupInfo',
_buildParam({ _buildParam({
"gid": groupID,
'gInfo': { 'gInfo': {
"groupID": groupID, // "groupID": groupID,
"groupName": groupName, "groupName": groupName,
"notification": notification, "notification": notification,
"introduction": introduction, "introduction": introduction,
"faceUrl": faceUrl, "faceURL": faceUrl,
"ex": ex,
}, },
'operationID': Utils.checkOperationID(operationID),
})); }));
}
/// Find group information by group id /// Find group information by group id
/// 查询组信息
Future<List<GroupInfo>> getGroupsInfo({ Future<List<GroupInfo>> getGroupsInfo({
required List<String> gidList, required List<String> gidList,
}) { String? operationID,
return _channel }) =>
.invokeMethod('getGroupsInfo', _buildParam({'gidList': gidList})) _channel
.then((value) { .invokeMethod(
List list = _formatJson(value); 'getGroupsInfo',
return list.map((e) => GroupInfo.fromJson(e)).toList(); _buildParam({
}); 'gidList': gidList,
} 'operationID': Utils.checkOperationID(operationID),
}))
.then(
(value) => Utils.toList(value, (map) => GroupInfo.fromJson(map)));
/// Apply to join the group /// Apply to join the group
/// 申请加入组,需要通过管理员同意。
Future<dynamic> joinGroup({ Future<dynamic> joinGroup({
required String gid, required String gid,
String? reason, String? reason,
}) { String? operationID,
return _channel.invokeMethod( }) =>
_channel.invokeMethod(
'joinGroup', 'joinGroup',
_buildParam({ _buildParam({
'gid': gid, 'gid': gid,
'reason': reason, 'reason': reason,
'operationID': Utils.checkOperationID(operationID),
})); }));
}
/// Leave group /// Leave group
/// 退出组
Future<dynamic> quitGroup({ Future<dynamic> quitGroup({
required String gid, required String gid,
}) { String? operationID,
return _channel.invokeMethod( }) =>
_channel.invokeMethod(
'quitGroup', 'quitGroup',
_buildParam({ _buildParam({
'gid': gid, 'gid': gid,
'operationID': Utils.checkOperationID(operationID),
})); }));
}
/// Give group permissions to others /// Give group permissions to others
/// 转移组拥有者权限
Future<dynamic> transferGroupOwner({ Future<dynamic> transferGroupOwner({
required String gid, required String gid,
required String uid, required String uid,
}) { String? operationID,
return _channel.invokeMethod( }) =>
_channel.invokeMethod(
'transferGroupOwner', 'transferGroupOwner',
_buildParam({ _buildParam({
'gid': gid, 'gid': gid,
'uid': uid, 'uid': uid,
'operationID': Utils.checkOperationID(operationID),
})); }));
}
/// Get the list of applications /// As the group owner or administrator, get the list of received group members' applications to join the group.
Future<GroupApplicationList> getGroupApplicationList() { /// 作为群主或者管理员,获取收到的群成员申请进群列表。
return _channel Future<List<GroupApplicationInfo>> getRecvGroupApplicationList(
.invokeMethod('getGroupApplicationList', _buildParam({})) {String? operationID}) =>
.then((value) => GroupApplicationList.fromJson(_formatJson(value))); _channel
} .invokeMethod(
'getRecvGroupApplicationList',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
/// Get the record of the group membership application issued by yourself
/// 获取自己发出的入群申请记录
Future<List<GroupApplicationInfo>> getSendGroupApplicationList(
{String? operationID}) =>
_channel
.invokeMethod(
'getSendGroupApplicationList',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) =>
Utils.toList(value, (map) => GroupApplicationInfo.fromJson(map)));
/// Accept group application /// Accept group application
/// 管理员或者群主同意某人进入某群
Future<dynamic> acceptGroupApplication({ Future<dynamic> acceptGroupApplication({
required GroupApplicationInfo info, required String gid,
required String reason, required String uid,
}) { String? handleMsg,
return _channel.invokeMethod( String? operationID,
}) =>
_channel.invokeMethod(
'acceptGroupApplication', 'acceptGroupApplication',
_buildParam({ _buildParam({
'application': info.toJson(), 'gid': gid,
'reason': reason, 'uid': uid,
'handleMsg': handleMsg,
'operationID': Utils.checkOperationID(operationID),
})); }));
}
/// Refuse group application /// Refuse group application
/// 管理员或者群主拒绝某人进入某群
Future<dynamic> refuseGroupApplication({ Future<dynamic> refuseGroupApplication({
required GroupApplicationInfo info, required String gid,
required String reason, required String uid,
}) { String? handleMsg,
return _channel.invokeMethod( String? operationID,
}) =>
_channel.invokeMethod(
'refuseGroupApplication', 'refuseGroupApplication',
_buildParam({ _buildParam({
'application': info.toJson(), 'gid': gid,
'reason': reason, 'uid': uid,
'handleMsg': handleMsg,
'operationID': Utils.checkOperationID(operationID),
})); }));
}
///
// Future forceSyncApplyGroupRequest() {
// return _channel.invokeMethod('forceSyncApplyGroupRequest', _buildParam({}));
// }
///
// Future forceSyncGroupRequest() {
// return _channel.invokeMethod('forceSyncGroupRequest', _buildParam({}));
// }
///
// Future forceSyncJoinedGroup() {
// return _channel.invokeMethod('forceSyncJoinedGroup', _buildParam({}));
// }
///
// Future forceSyncJoinedGroupMember() {
// return _channel.invokeMethod('forceSyncJoinedGroupMember', _buildParam({}));
// }
static Map _buildParam(Map param) { static Map _buildParam(Map param) {
param["ManagerName"] = "groupManager"; param["ManagerName"] = "groupManager";
return param; return param;
} }
static dynamic _formatJson(value) {
return jsonDecode(_printValue(value));
}
static String _printValue(value) {
return value;
}
} }

View File

@@ -1,4 +1,4 @@
import 'dart:convert'; import 'dart:developer';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
@@ -9,13 +9,13 @@ class IMManager {
late FriendshipManager friendshipManager; late FriendshipManager friendshipManager;
late MessageManager messageManager; late MessageManager messageManager;
late GroupManager groupManager; late GroupManager groupManager;
late UserManager userManager;
// late OfflinePushManager offlinePushManager; // late OfflinePushManager offlinePushManager;
// late SignalingManager signalingManager; // late SignalingManager signalingManager;
late InitSDKListener _initSDKListener; late OnConnectListener _connectListener;
late String uid; late String uid;
late UserInfo uInfo; late UserInfo uInfo;
bool isInitialized = false;
bool isLogined = false; bool isLogined = false;
IMManager(this._channel) { IMManager(this._channel) {
@@ -23,6 +23,7 @@ class IMManager {
friendshipManager = FriendshipManager(_channel); friendshipManager = FriendshipManager(_channel);
messageManager = MessageManager(_channel); messageManager = MessageManager(_channel);
groupManager = GroupManager(_channel); groupManager = GroupManager(_channel);
userManager = UserManager(_channel);
// offlinePushManager = OfflinePushManager(_channel); // offlinePushManager = OfflinePushManager(_channel);
// signalingManager = SignalingManager(_channel); // signalingManager = SignalingManager(_channel);
_addNativeCallback(_channel); _addNativeCallback(_channel);
@@ -31,113 +32,88 @@ class IMManager {
void _addNativeCallback(MethodChannel _channel) { void _addNativeCallback(MethodChannel _channel) {
_channel.setMethodCallHandler((call) { _channel.setMethodCallHandler((call) {
try { try {
print('call:$call'); log('Flutter : $call');
if (call.method == ListenerType.initSDKListener) { if (call.method == ListenerType.connectListener) {
String type = call.arguments['type'];
switch (type) {
case 'onConnectFailed':
int? errCode = call.arguments['errCode'];
String? errMsg = call.arguments['errMsg'];
_connectListener.connectFailed(errCode, errMsg);
break;
case 'onConnecting':
_connectListener.connecting();
break;
case 'onConnectSuccess':
_connectListener.connectSuccess();
break;
case 'onKickedOffline':
_connectListener.kickedOffline();
break;
case 'onUserSigExpired':
_connectListener.userSigExpired();
break;
}
} else if (call.method == ListenerType.userListener) {
String type = call.arguments['type']; String type = call.arguments['type'];
dynamic data = call.arguments['data']; dynamic data = call.arguments['data'];
switch (type) { switch (type) {
case 'onSelfInfoUpdated': case 'onSelfInfoUpdated':
uInfo = UserInfo.fromJson(_formatJson(data)); uInfo = Utils.toObj(data, (map) => UserInfo.fromJson(map));
_initSDKListener.selfInfoUpdated(uInfo); userManager.userListener.selfInfoUpdated(uInfo);
break;
case 'onConnectFailed':
int? errCode = call.arguments['errCode'];
String? errMsg = call.arguments['errMsg'];
_initSDKListener.connectFailed(errCode, errMsg);
break;
case 'onConnecting':
_initSDKListener.connecting();
break;
case 'onConnectSuccess':
_initSDKListener.connectSuccess();
break;
case 'onKickedOffline':
_initSDKListener.kickedOffline();
break;
case 'onUserSigExpired':
_initSDKListener.userSigExpired();
break; break;
} }
} else if (call.method == ListenerType.groupListener) { } else if (call.method == ListenerType.groupListener) {
var args = call.arguments; String type = call.arguments['type'];
String type = args['type']; dynamic data = call.arguments['data'];
Map<dynamic, dynamic> map = args['data'];
switch (type) { switch (type) {
case 'onMemberEnter': case 'onGroupApplicationAccepted':
groupManager.groupListener.memberEnter( final i = Utils.toObj(
map['groupId'], data, (map) => GroupApplicationInfo.fromJson(map));
(_formatJson(map['memberList']) as List) groupManager.groupListener.groupApplicationAccepted(i);
.map((e) => GroupMembersInfo.fromJson(e))
.toList(),
);
break; break;
case 'onMemberLeave': case 'onGroupApplicationAdded':
groupManager.groupListener.memberLeave( final i = Utils.toObj(
map['groupId'], data, (map) => GroupApplicationInfo.fromJson(map));
GroupMembersInfo.fromJson(_formatJson(map['member'])), groupManager.groupListener.groupApplicationAdded(i);
);
break; break;
case 'onMemberInvited': case 'onGroupApplicationDeleted':
groupManager.groupListener.memberInvited( final i = Utils.toObj(
map['groupId'], data, (map) => GroupApplicationInfo.fromJson(map));
GroupMembersInfo.fromJson(_formatJson(map['opUser'])), groupManager.groupListener.groupApplicationDeleted(i);
(_formatJson(map['memberList']) as List)
.map((e) => GroupMembersInfo.fromJson(e))
.toList(),
);
break; break;
case 'onMemberKicked': case 'onGroupApplicationRejected':
groupManager.groupListener.memberKicked( final i = Utils.toObj(
map['groupId'], data, (map) => GroupApplicationInfo.fromJson(map));
GroupMembersInfo.fromJson(_formatJson(map['opUser'])), groupManager.groupListener.groupApplicationRejected(i);
(_formatJson(map['memberList']) as List)
.map((e) => GroupMembersInfo.fromJson(e))
.toList(),
);
break;
case 'onGroupCreated':
groupManager.groupListener.groupCreated(
map['groupId'],
);
break; break;
case 'onGroupInfoChanged': case 'onGroupInfoChanged':
groupManager.groupListener.groupInfoChanged( final i = Utils.toObj(data, (map) => GroupInfo.fromJson(map));
map['groupId'], groupManager.groupListener.groupInfoChanged(i);
GroupInfo.fromJson(_formatJson(map['groupInfo'])),
);
break; break;
case 'onReceiveJoinApplication': case 'onGroupMemberAdded':
groupManager.groupListener.receiveJoinApplication( final i =
map['groupId'], Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
GroupMembersInfo.fromJson(_formatJson(map['member'])), groupManager.groupListener.groupMemberAdded(i);
map['opReason'],
);
break; break;
case 'onApplicationProcessed': case 'onGroupMemberDeleted':
groupManager.groupListener.applicationProcessed( final i =
map['groupId'], Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
GroupMembersInfo.fromJson(_formatJson(map['opUser'])), groupManager.groupListener.groupMemberDeleted(i);
map['agreeOrReject'], break;
map['opReason'], case 'onGroupMemberInfoChanged':
); final i =
Utils.toObj(data, (map) => GroupMembersInfo.fromJson(map));
groupManager.groupListener.groupMemberInfoChanged(i);
break;
case 'onJoinedGroupAdded':
final i = Utils.toObj(data, (map) => GroupInfo.fromJson(map));
groupManager.groupListener.joinedGroupAdded(i);
break;
case 'onJoinedGroupDeleted':
final i = Utils.toObj(data, (map) => GroupInfo.fromJson(map));
groupManager.groupListener.joinedGroupDeleted(i);
break; break;
// case 'onMemberInfoChanged':
// break;
// case 'onGroupDismissed':
// break;
// case 'onGroupRecycled':
// break;
//
// case 'onGrantAdministrator':
// break;
// case 'onRevokeAdministrator':
// break;
// case 'onQuitFromGroup':
// break;
// case 'onReceiveRESTCustomData':
// break;
// case 'onGroupAttributeChanged':
// break;
} }
} else if (call.method == ListenerType.advancedMsgListener) { } else if (call.method == ListenerType.advancedMsgListener) {
var type = call.arguments['type']; var type = call.arguments['type'];
@@ -145,30 +121,18 @@ class IMManager {
switch (type) { switch (type) {
case 'onRecvNewMessage': case 'onRecvNewMessage':
var value = call.arguments['data']['newMessage']; var value = call.arguments['data']['newMessage'];
var msg = Message.fromJson(_formatJson(value)); final msg = Utils.toObj(value, (map) => Message.fromJson(map));
for (var listener in messageManager.advancedMsgListeners) { messageManager.advancedMsgListener.recvNewMessage(msg);
if (listener.id == id) {
listener.recvNewMessage(msg);
}
}
break; break;
case 'onRecvMessageRevoked': case 'onRecvMessageRevoked':
var value = call.arguments['data']['revokedMessage']; var value = call.arguments['data']['revokedMessage'];
for (var listener in messageManager.advancedMsgListeners) { messageManager.advancedMsgListener.recvMessageRevoked(value);
if (listener.id == id) {
listener.recvMessageRevoked(value);
}
}
break; break;
case 'onRecvC2CReadReceipt': case 'onRecvC2CReadReceipt':
var value = call.arguments['data']['haveReadMessage']; var value = call.arguments['data']['haveReadMessage'];
var l = _formatJson(value) as List; var list =
var list = l.map((e) => HaveReadInfo.fromJson(e)).toList(); Utils.toList(value, (map) => ReadReceiptInfo.fromJson(map));
for (var listener in messageManager.advancedMsgListeners) { messageManager.advancedMsgListener.recvC2CReadReceipt(list);
if (listener.id == id) {
listener.recvC2CReadReceipt(list);
}
}
break; break;
} }
} else if (call.method == ListenerType.msgSendProgressListener) { } else if (call.method == ListenerType.msgSendProgressListener) {
@@ -187,7 +151,6 @@ class IMManager {
} else if (call.method == ListenerType.conversationListener) { } else if (call.method == ListenerType.conversationListener) {
String type = call.arguments['type']; String type = call.arguments['type'];
dynamic data = call.arguments['data']; dynamic data = call.arguments['data'];
print('type:$type data:$data');
switch (type) { switch (type) {
case 'onSyncServerStart': case 'onSyncServerStart':
conversationManager.conversationListener.syncServerStart(); conversationManager.conversationListener.syncServerStart();
@@ -200,21 +163,13 @@ class IMManager {
conversationManager.conversationListener.syncServerFailed(); conversationManager.conversationListener.syncServerFailed();
break; break;
case 'onNewConversation': case 'onNewConversation':
List<ConversationInfo> list = List.empty(growable: true); var list =
if (null != data) { Utils.toList(data, (map) => ConversationInfo.fromJson(map));
list = (_formatJson(data) as List)
.map((e) => ConversationInfo.fromJson(e))
.toList();
}
conversationManager.conversationListener.newConversation(list); conversationManager.conversationListener.newConversation(list);
break; break;
case 'onConversationChanged': case 'onConversationChanged':
List<ConversationInfo> list = List.empty(growable: true); var list =
if (null != data) { Utils.toList(data, (map) => ConversationInfo.fromJson(map));
list = (_formatJson(data) as List)
.map((e) => ConversationInfo.fromJson(e))
.toList();
}
conversationManager.conversationListener conversationManager.conversationListener
.conversationChanged(list); .conversationChanged(list);
break; break;
@@ -226,44 +181,53 @@ class IMManager {
} else if (call.method == ListenerType.friendListener) { } else if (call.method == ListenerType.friendListener) {
String type = call.arguments['type']; String type = call.arguments['type'];
dynamic data = call.arguments['data']; dynamic data = call.arguments['data'];
UserInfo u = UserInfo.fromJson(_formatJson(data));
switch (type) { switch (type) {
case 'onBlackListAdd': case 'onBlacklistAdded':
friendshipManager.friendshipListener.blackListAdd(u); final u = Utils.toObj(data, (map) => BlacklistInfo.fromJson(map));
friendshipManager.friendshipListener.blacklistAdded(u);
break; break;
case 'onBlackListDeleted': case 'onBlacklistDeleted':
friendshipManager.friendshipListener.blackListDeleted(u); final u = Utils.toObj(data, (map) => BlacklistInfo.fromJson(map));
friendshipManager.friendshipListener.blacklistDeleted(u);
break; break;
case 'onFriendApplicationListAccept': case 'onFriendApplicationAccepted':
friendshipManager.friendshipListener final u = Utils.toObj(
.friendApplicationListAccept(u); data, (map) => FriendApplicationInfo.fromJson(map));
friendshipManager.friendshipListener.friendApplicationAccepted(u);
break; break;
case 'onFriendApplicationListAdded': case 'onFriendApplicationAdded':
friendshipManager.friendshipListener final u = Utils.toObj(
.friendApplicationListAdded(u); data, (map) => FriendApplicationInfo.fromJson(map));
friendshipManager.friendshipListener.friendApplicationAdded(u);
break; break;
case 'onFriendApplicationListDeleted': case 'onFriendApplicationDeleted':
friendshipManager.friendshipListener final u = Utils.toObj(
.friendApplicationListDeleted(u); data, (map) => FriendApplicationInfo.fromJson(map));
friendshipManager.friendshipListener.friendApplicationDeleted(u);
break; break;
case 'onFriendApplicationListReject': case 'onFriendApplicationListRejected':
friendshipManager.friendshipListener final u = Utils.toObj(
.friendApplicationListReject(u); data, (map) => FriendApplicationInfo.fromJson(map));
friendshipManager.friendshipListener.friendApplicationRejected(u);
break; break;
case 'onFriendInfoChanged': case 'onFriendInfoChanged':
final u = Utils.toObj(data, (map) => FriendInfo.fromJson(map));
friendshipManager.friendshipListener.friendInfoChanged(u); friendshipManager.friendshipListener.friendInfoChanged(u);
break; break;
case 'onFriendListAdded': case 'onFriendAdded':
friendshipManager.friendshipListener.friendListAdded(u); final u = Utils.toObj(data, (map) => FriendInfo.fromJson(map));
friendshipManager.friendshipListener.friendAdded(u);
break; break;
case 'onFriendListDeleted': case 'onFriendDeleted':
friendshipManager.friendshipListener.friendListDeleted(u); final u = Utils.toObj(data, (map) => FriendInfo.fromJson(map));
friendshipManager.friendshipListener.friendDeleted(u);
break; break;
} }
} }
} catch (err) { } catch (err) {
print( print(
"回调失败了,数据类型异常$err ${call.method} ${call.arguments['type']} ${call.arguments['data']}"); "回调失败了。$err ${call.method} ${call.arguments['type']} ${call.arguments['data']}");
} }
return Future.value(null); return Future.value(null);
}); });
@@ -271,136 +235,95 @@ class IMManager {
/// Initialize SDK /// Initialize SDK
/// ///
/// [platform] Refer to [IMPlatform] /// [platform] platform number [IMPlatform]
/// [ipApi] Api server ip address /// [apiAddr] api server ip address
/// [ipWs] WebSocket ip address /// [wsAddr] webSocket ip address
/// [dbPath] Data storage directory /// [dataDir] data storage directory
///
/// 初始化SDK
///
/// [platform] 平台编号[IMPlatform]
/// [apiAddr] SDK api地址
/// [wsAddr] SDK websocket地址
/// [dataDir] SDK数据库存储目录
Future<dynamic> initSDK({ Future<dynamic> initSDK({
required int platform, required int platform,
required String ipApi, required String apiAddr,
required String ipWs, required String wsAddr,
required String dbPath, required String dataDir,
required InitSDKListener listener, required OnConnectListener listener,
int logLevel = 6,
String objectStorage = 'cos',
String? operationID,
}) { }) {
_initSDKListener = listener; _connectListener = listener;
return _channel return _channel.invokeMethod(
.invokeMethod(
'initSDK', 'initSDK',
_buildParam( _buildParam(
{ {
"platform": platform, "platform": platform,
"ipApi": ipApi, "api_addr": apiAddr,
"ipWs": ipWs, "ws_addr": wsAddr,
"dbDir": dbPath "data_dir": dataDir,
"log_level": logLevel,
"object_storage": objectStorage,
"operationID": Utils.checkOperationID(operationID),
}, },
)) ));
.then((value) => isInitialized = true);
} }
@deprecated @deprecated
Future<dynamic> unInitSDK() { Future<dynamic> unInitSDK() {
return _channel.invokeMethod('unInitSDK', _buildParam({})).then((value) { return _channel.invokeMethod('unInitSDK', _buildParam({}));
isInitialized = false;
return value;
});
} }
/// Login sdk /// Login sdk
Future<UserInfo> login({required String uid, required String token}) async { /// 登录
this.uid = uid; Future<UserInfo> login({
required String uid,
required String token,
String? operationID,
}) async {
await _channel.invokeMethod( await _channel.invokeMethod(
'login', 'login',
_buildParam({'uid': uid, 'token': token}), _buildParam({
'uid': uid,
'token': token,
'operationID': Utils.checkOperationID(operationID),
}),
); );
this.isLogined = true; this.isLogined = true;
this.uInfo = (await getUsersInfo([uid])).first; this.uid = uid;
this.uInfo = await userManager.getSelfUserInfo();
return uInfo; return uInfo;
} }
/// Logout sdk /// Logout sdk
Future<dynamic> logout() async { /// 登出
var value = await _channel.invokeMethod('logout', _buildParam({})); Future<dynamic> logout({String? operationID}) async {
var value = await _channel.invokeMethod(
'logout',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}));
this.isLogined = false; this.isLogined = false;
return value; return value;
} }
/// ///
Future<int?> getLoginStatus() { Future<int?> getLoginStatus() =>
return _channel.invokeMethod<int>('getLoginStatus', _buildParam({})); _channel.invokeMethod<int>('getLoginStatus', _buildParam({}));
}
/// Current user id /// Current user id
Future<String?> getLoginUid() { /// 获取当前登录用户id
return Future.value(uid); Future<String> getLoginUserID() async => uid;
// return _channel.invokeMethod<String>('getLoginUid', _buildParam({}));
}
/// Current user info /// Current user info
Future<UserInfo> getLoginUserInfo() { /// 获取当前登录用户信息
return Future.value(uInfo); Future<UserInfo> getLoginUserInfo() async => uInfo;
}
/// Modify current user info
Future<String?> setSelfInfo(
{required String uid,
String? name,
String? icon,
int? gender,
String? mobile,
String? birth,
String? email,
String? ex}) {
return _channel.invokeMethod(
'setSelfInfo',
_buildParam({
'uid': uid,
'name': name,
'icon': icon,
'gender': gender,
'mobile': mobile,
'birth': birth,
'email': email,
'ex': ex,
}));
// .then((value) => UserInfo.fromJson(value));
}
/// Query user information
Future<List<UserInfo>> getUsersInfo(List<String> uidList) {
return _channel
.invokeMethod('getUsersInfo', _buildParam({'uidList': uidList}))
.then((value) => _toList(value));
}
///
void enabledSDKLog({required bool enabled}) {
_channel.invokeMethod(
'setSdkLog', _buildParam({'sdkLog': enabled ? 0 : 1}));
}
///
Future<dynamic> forceSyncLoginUerInfo(List<String> uidList) {
return _channel.invokeMethod('forceSyncLoginUerInfo', _buildParam({}));
}
///
// Future<dynamic> forceReConn() {
// return _channel.invokeMethod('forceReConn', _buildParam({}));
// }
static Map _buildParam(Map param) { static Map _buildParam(Map param) {
param["ManagerName"] = "imManager"; param["ManagerName"] = "imManager";
return param; return param;
} }
static List<UserInfo> _toList(String value) =>
(_formatJson(value) as List).map((e) => UserInfo.fromJson(e)).toList();
static dynamic _formatJson(value) {
return jsonDecode(_printValue(value));
}
static String _printValue(value) {
return value;
}
} }

View File

@@ -1,224 +1,277 @@
import 'dart:convert';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart'; import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class MessageManager { class MessageManager {
MethodChannel _channel; MethodChannel _channel;
List<AdvancedMsgListener> advancedMsgListeners = List.empty(growable: true);
MsgSendProgressListener? msgSendProgressListener; // List<AdvancedMsgListener> advancedMsgListeners = List.empty(growable: true);
OnMsgSendProgressListener? msgSendProgressListener;
late OnAdvancedMsgListener advancedMsgListener;
MessageManager(this._channel); MessageManager(this._channel);
/// Add a message listener /// Set a message listener
Future addAdvancedMsgListener(AdvancedMsgListener listener) { /// 消息监听
advancedMsgListeners.add(listener); Future setAdvancedMsgListener(OnAdvancedMsgListener listener) {
this.advancedMsgListener = listener;
// advancedMsgListeners.add(listener);
return _channel.invokeMethod( return _channel.invokeMethod(
'addAdvancedMsgListener', 'setAdvancedMsgListener',
_buildParam({
'id': listener.id,
}));
}
/// Remove a message listener
Future removeAdvancedMsgListener(AdvancedMsgListener listener) {
advancedMsgListeners.remove(listener);
return _channel.invokeMethod(
'removeAdvancedMsgListener',
_buildParam({ _buildParam({
'id': listener.id, 'id': listener.id,
})); }));
} }
/// Set up message sending progress monitoring /// Set up message sending progress monitoring
void setMsgSendProgressListener(MsgSendProgressListener listener) { /// 消息发送进度监听
void setMsgSendProgressListener(OnMsgSendProgressListener listener) {
msgSendProgressListener = listener; msgSendProgressListener = listener;
} }
/// Send a message to user or to group /// Send a message to user or to group
/// [userID] receiver's user ID /// [userID] receiver's user ID
Future<dynamic> sendMessage({ /// 发送消息
/// [userID]接收消息的用户id
/// [groupID]接收消息的组id
/// [offlinePushInfo]离线消息显示内容
Future<Message> sendMessage({
required Message message, required Message message,
required OfflinePushInfo offlinePushInfo,
String? userID, String? userID,
String? groupID, String? groupID,
bool onlineUserOnly = false, String? operationID,
}) { }) =>
return _channel.invokeMethod( _channel
.invokeMethod(
'sendMessage', 'sendMessage',
_buildParam({ _buildParam({
'message': message.toJson(), 'message': message.toJson(),
'receiver': userID ?? '', 'offlinePushInfo': offlinePushInfo.toJson(),
'userID': userID ?? '',
'groupID': groupID ?? '', 'groupID': groupID ?? '',
'onlineUserOnly': onlineUserOnly, 'operationID': Utils.checkOperationID(operationID),
})) /*.then((value) => _toObj(value))*/; }))
} .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// Find all history message /// Find all history message
/// 获取聊天记录
/// [userID]接收消息的用户id
/// [groupID]接收消息的组id
Future<List<Message>> getHistoryMessageList({ Future<List<Message>> getHistoryMessageList({
String? userID, String? userID,
String? groupID, String? groupID,
Message? startMsg, Message? startMsg,
int? count, int? count,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'getHistoryMessageList', 'getHistoryMessageList',
_buildParam({ _buildParam({
'userID': userID ?? '', 'userID': userID ?? '',
'startMsg': startMsg?.toJson() /*?? {}*/,
'groupID': groupID ?? '', 'groupID': groupID ?? '',
'startClientMsgID': startMsg?.clientMsgID ?? '',
'count': count ?? 10, 'count': count ?? 10,
'operationID': Utils.checkOperationID(operationID),
})) }))
.then((value) => _toList(value)); .then((value) => Utils.toList(value, (map) => Message.fromJson(map)));
}
/// Revoke the sent information /// Revoke the sent information
Future revokeMessage({required Message message}) { /// 撤回消息
return _channel.invokeMethod( Future revokeMessage({
'revokeMessage', _buildParam(message.toJson())); required Message message,
} String? operationID,
}) =>
_channel.invokeMethod(
'revokeMessage',
_buildParam(message.toJson()
..addAll({
"operationID": Utils.checkOperationID(operationID),
})));
/// Delete message /// Delete message
Future deleteMessageFromLocalStorage({required Message message}) { /// 删除消息
return _channel.invokeMethod( Future deleteMessageFromLocalStorage({
'deleteMessageFromLocalStorage', _buildParam(message.toJson())); required Message message,
} String? operationID,
}) =>
_channel.invokeMethod(
'deleteMessageFromLocalStorage',
_buildParam(message.toJson()
..addAll({
"operationID": Utils.checkOperationID(operationID),
})));
/// ///
@deprecated // Future deleteMessages({required List<Message> msgList}) =>
Future deleteMessages({required List<Message> msgList}) { // _channel.invokeMethod('deleteMessages',
return _channel.invokeMethod('deleteMessages', // _buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
_buildParam({"msgList": msgList.map((e) => e.toJson()).toList()}));
}
/// ///
Future insertSingleMessageToLocalStorage({ Future insertSingleMessageToLocalStorage({
String? receiver, String? receiverID,
String? sender, String? senderID,
Message? message, Message? message,
}) { String? operationID,
return _channel.invokeMethod( }) =>
_channel.invokeMethod(
'insertSingleMessageToLocalStorage', 'insertSingleMessageToLocalStorage',
_buildParam({ _buildParam({
"userID": receiver,
"message": message?.toJson(), "message": message?.toJson(),
"sender": sender, "receiverID": receiverID,
"senderID": senderID,
"operationID": Utils.checkOperationID(operationID),
})); }));
}
/// Query the message according to the message id /// Query the message according to the message id
Future findMessages({required List<String> messageIDList}) { // Future findMessages({required List<String> messageIDList}) =>
return _channel.invokeMethod( // _channel.invokeMethod(
'findMessages', // 'findMessages',
_buildParam({ // _buildParam({
"messageIDList": messageIDList, // "messageIDList": messageIDList,
})); // }));
}
/// Mark c2c message as read /// Mark c2c message as read
/// 标记c2c消息已读
Future markC2CMessageAsRead({ Future markC2CMessageAsRead({
required String userID, required String userID,
required List<String> messageIDList, required List<String> messageIDList,
}) { String? operationID,
return _channel.invokeMethod( }) =>
_channel.invokeMethod(
'markC2CMessageAsRead', 'markC2CMessageAsRead',
_buildParam({ _buildParam({
"messageIDList": messageIDList, "messageIDList": messageIDList,
"userID": userID, "userID": userID,
"operationID": Utils.checkOperationID(operationID),
})); }));
}
/// Typing /// Typing
/// 正在输入提示
Future typingStatusUpdate({ Future typingStatusUpdate({
required String userID, required String userID,
bool typing = false, String? msgTip,
}) { String? operationID,
return _channel.invokeMethod( }) =>
_channel.invokeMethod(
'typingStatusUpdate', 'typingStatusUpdate',
_buildParam({ _buildParam({
"typing": typing ? 'yes' : 'no', "msgTip": msgTip,
"userID": userID, "userID": userID,
"operationID": Utils.checkOperationID(operationID),
})); }));
}
/// Create text message /// Create text message
Future<Message> createTextMessage({required String text}) { /// 创建文本消息
return _channel Future<Message> createTextMessage({
.invokeMethod('createTextMessage', _buildParam({'text': text})) required String text,
.then((value) => _toObj(value)); String? operationID,
} }) =>
_channel
.invokeMethod(
'createTextMessage',
_buildParam({
'text': text,
"operationID": Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
/// Create @ message /// Create @ message
/// 创建@消息
Future<Message> createTextAtMessage({ Future<Message> createTextAtMessage({
required String text, required String text,
required List<String> atUidList, required List<String> atUidList,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createTextAtMessage', 'createTextAtMessage',
_buildParam({ _buildParam({
'text': text, 'text': text,
'atUserList': atUidList, 'atUserList': atUidList,
"operationID": Utils.checkOperationID(operationID),
}), }),
) )
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create picture message /// Create picture message
Future<Message> createImageMessage({required String imagePath}) { /// 创建图片消息
return _channel Future<Message> createImageMessage({
required String imagePath,
String? operationID,
}) =>
_channel
.invokeMethod( .invokeMethod(
'createImageMessage', 'createImageMessage',
_buildParam({'imagePath': imagePath}), _buildParam({
'imagePath': imagePath,
"operationID": Utils.checkOperationID(operationID),
}),
) )
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create picture message /// Create picture message
Future<Message> createImageMessageFromFullPath({required String imagePath}) { /// 创建图片消息
return _channel Future<Message> createImageMessageFromFullPath({
required String imagePath,
String? operationID,
}) =>
_channel
.invokeMethod( .invokeMethod(
'createImageMessageFromFullPath', 'createImageMessageFromFullPath',
_buildParam({'imagePath': imagePath}), _buildParam({
'imagePath': imagePath,
"operationID": Utils.checkOperationID(operationID),
}),
) )
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create sound message /// Create sound message
/// 创建语音消息
Future<Message> createSoundMessage({ Future<Message> createSoundMessage({
required String soundPath, required String soundPath,
required int duration, required int duration,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createSoundMessage', 'createSoundMessage',
_buildParam({'soundPath': soundPath, "duration": duration}), _buildParam({
'soundPath': soundPath,
"duration": duration,
"operationID": Utils.checkOperationID(operationID),
}),
) )
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create sound message /// Create sound message
/// 创建语音消息
Future<Message> createSoundMessageFromFullPath({ Future<Message> createSoundMessageFromFullPath({
required String soundPath, required String soundPath,
required int duration, required int duration,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createSoundMessageFromFullPath', 'createSoundMessageFromFullPath',
_buildParam({'soundPath': soundPath, "duration": duration}), _buildParam({
'soundPath': soundPath,
"duration": duration,
"operationID": Utils.checkOperationID(operationID),
}),
) )
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create video message /// Create video message
/// 创建视频消息
Future<Message> createVideoMessage({ Future<Message> createVideoMessage({
required String videoPath, required String videoPath,
required String videoType, required String videoType,
required int duration, required int duration,
required String snapshotPath, required String snapshotPath,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createVideoMessage', 'createVideoMessage',
_buildParam({ _buildParam({
@@ -226,18 +279,20 @@ class MessageManager {
'videoType': videoType, 'videoType': videoType,
'duration': duration, 'duration': duration,
'snapshotPath': snapshotPath, 'snapshotPath': snapshotPath,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create video message /// Create video message
/// 创建视频消息
Future<Message> createVideoMessageFromFullPath({ Future<Message> createVideoMessageFromFullPath({
required String videoPath, required String videoPath,
required String videoType, required String videoType,
required int duration, required int duration,
required String snapshotPath, required String snapshotPath,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createVideoMessageFromFullPath', 'createVideoMessageFromFullPath',
_buildParam({ _buildParam({
@@ -245,14 +300,16 @@ class MessageManager {
'videoType': videoType, 'videoType': videoType,
'duration': duration, 'duration': duration,
'snapshotPath': snapshotPath, 'snapshotPath': snapshotPath,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create file message /// Create file message
/// 创建文件消息
Future<Message> createFileMessage({ Future<Message> createFileMessage({
required String filePath, required String filePath,
required String fileName, required String fileName,
String? operationID,
}) { }) {
return _channel return _channel
.invokeMethod( .invokeMethod(
@@ -260,147 +317,161 @@ class MessageManager {
_buildParam({ _buildParam({
'filePath': filePath, 'filePath': filePath,
'fileName': fileName, 'fileName': fileName,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
} }
/// Create file message /// Create file message
/// 创建文件消息
Future<Message> createFileMessageFromFullPath({ Future<Message> createFileMessageFromFullPath({
required String filePath, required String filePath,
required String fileName, required String fileName,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createFileMessageFromFullPath', 'createFileMessageFromFullPath',
_buildParam({ _buildParam({
'filePath': filePath, 'filePath': filePath,
'fileName': fileName, 'fileName': fileName,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create merger message /// Create merger message
/// 创建合并消息
Future<Message> createMergerMessage({ Future<Message> createMergerMessage({
required List<Message> messageList, required List<Message> messageList,
required String title, required String title,
required List<String> summaryList, required List<String> summaryList,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createMergerMessage', 'createMergerMessage',
_buildParam({ _buildParam({
'messageList': messageList.map((e) => e.toJson()).toList(), 'messageList': messageList.map((e) => e.toJson()).toList(),
'title': title, 'title': title,
'summaryList': summaryList, 'summaryList': summaryList,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create forward message /// Create forward message
Future<Message> createForwardMessage({required Message message}) { /// 创建转发消息
Future<Message> createForwardMessage({
required Message message,
String? operationID,
}) {
return _channel return _channel
.invokeMethod( .invokeMethod(
'createForwardMessage', 'createForwardMessage',
_buildParam({ _buildParam({
'message': message.toJson(), 'message': message.toJson(),
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
} }
/// Create location message /// Create location message
/// 创建位置消息
Future<Message> createLocationMessage({ Future<Message> createLocationMessage({
required double latitude, required double latitude,
required double longitude, required double longitude,
required String description, required String description,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createLocationMessage', 'createLocationMessage',
_buildParam({ _buildParam({
'latitude': latitude, 'latitude': latitude,
'longitude': longitude, 'longitude': longitude,
'description': description, 'description': description,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create custom message /// Create custom message
/// 创建自定义消息
Future<Message> createCustomMessage({ Future<Message> createCustomMessage({
required String data, required String data,
required String extension, required String extension,
required String description, required String description,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createCustomMessage', 'createCustomMessage',
_buildParam({ _buildParam({
'data': data, 'data': data,
'extension': extension, 'extension': extension,
'description': description, 'description': description,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create quote message /// Create quote message
/// 创建引用消息
Future<Message> createQuoteMessage({ Future<Message> createQuoteMessage({
required String text, required String text,
required Message quoteMsg, required Message quoteMsg,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createQuoteMessage', 'createQuoteMessage',
_buildParam({ _buildParam({
'quoteText': text, 'quoteText': text,
'quoteMessage': quoteMsg.toJson(), 'quoteMessage': quoteMsg.toJson(),
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// Create card message /// Create card message
/// 创建卡片消息
Future<Message> createCardMessage({ Future<Message> createCardMessage({
required Map<String, dynamic> data, required Map<String, dynamic> data,
}) { String? operationID,
return _channel }) =>
_channel
.invokeMethod( .invokeMethod(
'createCardMessage', 'createCardMessage',
_buildParam({ _buildParam({
'cardMessage': data, 'cardMessage': data,
"operationID": Utils.checkOperationID(operationID),
})) }))
.then((value) => _toObj(value)); .then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
}
/// /// Clear all c2c history message
Future<dynamic> clearC2CHistoryMessage({required String uid}) { /// 清空单聊消息记录
return _channel.invokeMethod( Future<dynamic> clearC2CHistoryMessage({
'clearC2CHistoryMessage', _buildParam({"userID": uid})); required String uid,
} String? operationID,
}) =>
_channel.invokeMethod(
'clearC2CHistoryMessage',
_buildParam({
"userID": uid,
"operationID": Utils.checkOperationID(operationID),
}));
/// /// Clear all group history
Future<dynamic> clearGroupHistoryMessage({required String gid}) { /// 清空组消息记录
return _channel.invokeMethod( Future<dynamic> clearGroupHistoryMessage({
'clearGroupHistoryMessage', _buildParam({"groupID": gid})); required String gid,
} String? operationID,
}) =>
/// _channel.invokeMethod(
void forceSyncMsg() { 'clearGroupHistoryMessage',
_channel.invokeMethod('forceSyncMsg', _buildParam({})); _buildParam({
} "groupID": gid,
"operationID": Utils.checkOperationID(operationID),
}));
static Map _buildParam(Map param) { static Map _buildParam(Map param) {
param["ManagerName"] = "messageManager"; param["ManagerName"] = "messageManager";
return param; return param;
} }
static List<Message> _toList(String value) =>
(_formatJson(value) as List).map((e) => Message.fromJson(e)).toList();
static Message _toObj(String value) => Message.fromJson(_formatJson(value));
static dynamic _formatJson(value) {
return jsonDecode(_printValue(value));
}
static String _printValue(value) {
return value;
}
} }

View File

@@ -0,0 +1,77 @@
import 'package:flutter/services.dart';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
class UserManager {
MethodChannel _channel;
late OnUserListener userListener;
UserManager(this._channel);
/// Observe user info changes
/// 用户资料改变监听
Future setUserListener(OnUserListener listener) {
this.userListener = listener;
return _channel.invokeMethod('setUserListener', _buildParam({}));
}
/// Query user information
/// 获取用户资料
Future<List<UserInfo>> getUsersInfo({
required List<String> uidList,
String? operationID,
}) =>
_channel
.invokeMethod(
'getUsersInfo',
_buildParam({
'uidList': uidList,
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toList(value, (v) => UserInfo.fromJson(v)));
/// Get the information of the currently logged in user
/// 获取当前登录用户的信息
Future<UserInfo> getSelfUserInfo({
String? operationID,
}) =>
_channel
.invokeMethod(
'getSelfUserInfo',
_buildParam({
'operationID': Utils.checkOperationID(operationID),
}))
.then((value) => Utils.toObj(value, (map) => UserInfo.fromJson(map)));
/// Modify current user info
/// 修改当前登录用户资料
Future<String?> setSelfInfo({
String? nickname,
String? faceURL,
int? gender,
int? appMangerLevel,
String? phoneNumber,
int? birth,
String? email,
String? ex,
String? operationID,
}) =>
_channel.invokeMethod(
'setSelfInfo',
_buildParam({
// 'userID': userID,
'nickname': nickname,
'faceURL': faceURL,
'gender': gender,
'appMangerLevel': appMangerLevel,
'phoneNumber': phoneNumber,
'birth': birth,
'email': email,
'ex': ex,
'operationID': Utils.checkOperationID(operationID),
}));
static Map _buildParam(Map param) {
param["ManagerName"] = "userManager";
return param;
}
}

View File

@@ -1,123 +0,0 @@
import 'dart:convert';
import 'dart:io';
import 'package:flutter_openim_sdk/flutter_openim_sdk.dart';
extension MessageManagerV2 on MessageManager {
Message createTextMessageV2({required String text}) {
return _createMessage(contentType: MessageType.text)..content = text;
}
Message createTextAtMessageV2({
required String text,
required List<String> atUidList,
}) {
var atElem = AtElem(
text: text,
atUserList: atUidList,
isAtSelf: false,
);
return _createMessage(contentType: MessageType.at_text)
..forceList = atUidList
..atElem = atElem
..content = jsonEncode(atElem);
}
Message createImageMessageV2({
required String imagePath,
required String mineType,
required int size,
required int width,
required int height,
}) {
return _createMessage(contentType: MessageType.picture)
..pictureElem = PictureElem(
sourcePath: imagePath,
sourcePicture: PictureInfo(
type: mineType,
size: size,
width: width,
height: height,
),
);
}
Message createSoundMessageV2({
required String soundPath,
required int duration,
required int dataSize,
}) {
return _createMessage(contentType: MessageType.voice)
..soundElem = SoundElem(
soundPath: soundPath,
dataSize: dataSize,
duration: duration,
);
}
Message createVideoMessageV2({
required String videoPath,
required String videoType,
required int videoSize,
required int duration,
required String snapshotPath,
required int snapshotSize,
required int snapshotWidth,
required int snapshotHeight,
}) {
return _createMessage(contentType: MessageType.video)
..videoElem = VideoElem(
videoPath: videoPath,
videoSize: videoSize,
videoType: videoType,
duration: duration,
snapshotPath: snapshotPath,
snapshotSize: snapshotSize,
snapshotHeight: snapshotHeight,
snapshotWidth: snapshotWidth,
);
}
Message createFileMessageV2({
required String filePath,
required String fileName,
required int fileSize,
}) {
return _createMessage(contentType: MessageType.file)
..fileElem = FileElem(
fileName: fileName,
filePath: filePath,
fileSize: fileSize,
);
}
/* Message createMergerMessageV2({
required List<Message> messageList,
required String title,
required List<String> summaryList,
}) {
var message = _createMessage(contentType: MessageType.merger);
return message;
}
Message createForwardMessageV2({required List<Message> messageList}) {
var message = _createMessage();
return message;
}*/
static Message _createMessage({required contentType}) {
var now = DateTime.now();
return Message(
clientMsgID: 'flutter_client_${now.microsecondsSinceEpoch}',
createTime: now.millisecond ~/ 1000,
sendTime: now.millisecond ~/ 1000,
// sessionType: 0,//请求为单人会话1请求为群聊会话2
msgFrom: 100,
contentType: contentType,
status: MessageStatus.sending,
platformID: Platform.isAndroid ? IMPlatform.android : IMPlatform.ios,
sendID: OpenIM.iMManager.uid,
senderNickName: OpenIM.iMManager.uInfo.name,
);
}
}

View File

@@ -10,16 +10,16 @@ class ConversationInfo {
String? userID; String? userID;
String? groupID; String? groupID;
String? showName; String? showName;
String? faceUrl; String? faceURL;
int? recvMsgOpt; int? recvMsgOpt;
int? unreadCount; int? unreadCount;
int? groupAtType;
Message? latestMsg; Message? latestMsg;
int? latestMsgSendTime; int? latestMsgSendTime;
String? draftText; String? draftText;
int? draftTimestamp; int? draftTextTime;
bool? isPinned;
/// pinned value is 1 String? ext;
dynamic isPinned;
ConversationInfo( ConversationInfo(
{required this.conversationID, {required this.conversationID,
@@ -27,27 +27,24 @@ class ConversationInfo {
this.userID, this.userID,
this.groupID, this.groupID,
this.showName, this.showName,
this.faceUrl, this.faceURL,
this.recvMsgOpt, this.recvMsgOpt,
this.unreadCount, this.unreadCount,
this.latestMsg, this.latestMsg,
this.latestMsgSendTime, this.latestMsgSendTime,
this.draftText, this.draftText,
this.draftTimestamp, this.draftTextTime,
this.isPinned}); this.isPinned});
ConversationInfo.fromJson(Map<String, dynamic> json) ConversationInfo.fromJson(Map<String, dynamic> json)
: conversationID = json['conversationID'] { : conversationID = json['conversationID'] {
// conversationID = json['conversationID'];
conversationType = json['conversationType']; conversationType = json['conversationType'];
userID = json['userID']; userID = json['userID'];
groupID = json['groupID']; groupID = json['groupID'];
showName = json['showName']; showName = json['showName'];
faceUrl = json['faceUrl']; faceURL = json['faceURL'];
recvMsgOpt = json['recvMsgOpt']; recvMsgOpt = json['recvMsgOpt'];
unreadCount = json['unreadCount']; unreadCount = json['unreadCount'];
// latestMsg = json['latestMsg'];
// if (null != json['latestMsg']) {
try { try {
if (json['latestMsg'] is String) { if (json['latestMsg'] is String) {
latestMsg = Message.fromJson(jsonDecode(json['latestMsg'])); latestMsg = Message.fromJson(jsonDecode(json['latestMsg']));
@@ -55,36 +52,41 @@ class ConversationInfo {
latestMsg = Message.fromJson(json['latestMsg']); latestMsg = Message.fromJson(json['latestMsg']);
} }
} catch (e) {} } catch (e) {}
// }
latestMsgSendTime = json['latestMsgSendTime']; latestMsgSendTime = json['latestMsgSendTime'];
draftText = json['draftText']; draftText = json['draftText'];
draftTimestamp = json['draftTimestamp']; draftTextTime = json['draftTextTime'];
isPinned = json['isPinned']; isPinned = json['isPinned'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['conversationID'] = this.conversationID; data['conversationID'] = this.conversationID;
data['conversationType'] = this.conversationType; data['conversationType'] = this.conversationType;
data['userID'] = this.userID; data['userID'] = this.userID;
data['groupID'] = this.groupID; data['groupID'] = this.groupID;
data['showName'] = this.showName; data['showName'] = this.showName;
data['faceUrl'] = this.faceUrl; data['faceURL'] = this.faceURL;
data['recvMsgOpt'] = this.recvMsgOpt; data['recvMsgOpt'] = this.recvMsgOpt;
data['unreadCount'] = this.unreadCount; data['unreadCount'] = this.unreadCount;
data['latestMsg'] = this.latestMsg?.toJson(); data['latestMsg'] = this.latestMsg?.toJson();
data['latestMsgSendTime'] = this.latestMsgSendTime; data['latestMsgSendTime'] = this.latestMsgSendTime;
data['draftText'] = this.draftText; data['draftText'] = this.draftText;
data['draftTimestamp'] = this.draftTimestamp; data['draftTextTime'] = this.draftTextTime;
data['isPinned'] = this.isPinned; data['isPinned'] = this.isPinned;
return data; return data;
} }
bool get isSingleChat => conversationType == ConversationType.single_chat; bool get isSingleChat => conversationType == ConversationType.single;
bool get isGroupChat => conversationType == ConversationType.group_chat; bool get isGroupChat => conversationType == ConversationType.group;
bool get isTop => isPinned == 1; @override
bool operator ==(Object other) =>
identical(this, other) ||
other is ConversationInfo &&
runtimeType == other.runtimeType &&
conversationID == other.conversationID;
@override
int get hashCode => conversationID.hashCode;
} }

View File

@@ -3,249 +3,255 @@ class GroupInfo {
String? groupName; String? groupName;
String? notification; String? notification;
String? introduction; String? introduction;
String? faceUrl; String? faceURL;
String? ownerId; String? ownerUserID;
int? createTime; int? createTime;
int? memberCount; int? memberCount;
int? status;
String? creatorUserID;
int? groupType;
String? ex;
GroupInfo( GroupInfo({
{required this.groupID, required this.groupID,
this.groupName, this.groupName,
this.notification, this.notification,
this.introduction, this.introduction,
this.faceUrl, this.faceURL,
this.ownerId, this.ownerUserID,
this.createTime, this.createTime,
this.memberCount}); this.memberCount,
this.status,
this.creatorUserID,
this.groupType,
this.ex,
});
GroupInfo.fromJson(Map<String, dynamic> json) : groupID = json['groupID'] { GroupInfo.fromJson(Map<String, dynamic> json) : groupID = json['groupID'] {
/*groupID = json['groupID'];*/ /*groupID = json['groupID'];*/
groupName = json['groupName']; groupName = json['groupName'];
notification = json['notification']; notification = json['notification'];
introduction = json['introduction']; introduction = json['introduction'];
faceUrl = json['faceUrl']; faceURL = json['faceURL'];
ownerId = json['ownerId']; ownerUserID = json['ownerUserID'];
createTime = json['createTime']; createTime = json['createTime'];
memberCount = json['memberCount']; memberCount = json['memberCount'];
status = json['status'];
creatorUserID = json['creatorUserID'];
groupType = json['groupType'];
ex = json['ex'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['groupID'] = this.groupID; data['groupID'] = this.groupID;
data['groupName'] = this.groupName; data['groupName'] = this.groupName;
data['notification'] = this.notification; data['notification'] = this.notification;
data['introduction'] = this.introduction; data['introduction'] = this.introduction;
data['faceUrl'] = this.faceUrl; data['faceURL'] = this.faceURL;
data['ownerId'] = this.ownerId; data['ownerUserID'] = this.ownerUserID;
data['createTime'] = this.createTime; data['createTime'] = this.createTime;
data['memberCount'] = this.memberCount; data['memberCount'] = this.memberCount;
return data; data['status'] = this.status;
} data['creatorUserID'] = this.creatorUserID;
} data['groupType'] = this.groupType;
data['ex'] = this.ex;
class GroupMembersList {
int? nextSeq;
List<GroupMembersInfo>? data;
GroupMembersList({this.nextSeq, this.data});
GroupMembersList.fromJson(Map<String, dynamic> json) {
nextSeq = json['nextSeq'];
if (json['data'] is List) {
data = (json['data'] as List)
.map((e) => GroupMembersInfo.fromJson(e))
.toList();
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['nextSeq'] = this.nextSeq;
if (this.data != null) {
data['data'] = this.data!.map((v) => v.toJson()).toList();
}
return data; return data;
} }
} }
class GroupMembersInfo { class GroupMembersInfo {
String? groupID; String? groupID;
String? userId; String? userID;
int? role; String? nickname;
String? faceURL;
int? roleLevel;
int? joinTime; int? joinTime;
String? nickName; int? joinSource;
String? faceUrl; String? operatorUserID;
dynamic ext; String? ext;
GroupMembersInfo({ GroupMembersInfo({
this.groupID, this.groupID,
this.userId, this.userID,
this.role, this.roleLevel,
this.joinTime, this.joinTime,
this.nickName, this.nickname,
this.faceUrl, this.faceURL,
this.ext, this.ext,
this.joinSource,
this.operatorUserID,
}); });
GroupMembersInfo.fromJson(Map<String, dynamic> json) { GroupMembersInfo.fromJson(Map<String, dynamic> json) {
groupID = json['groupID']; groupID = json['groupID'];
userId = json['userId']; userID = json['userID'];
role = json['role']; roleLevel = json['roleLevel'];
joinTime = json['joinTime']; joinTime = json['joinTime'];
nickName = json['nickName']; nickname = json['nickname'];
faceUrl = json['faceUrl']; faceURL = json['faceURL'];
ext = json['ext']; ext = json['ext'];
joinSource = json['joinSource'];
operatorUserID = json['operatorUserID'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['groupID'] = this.groupID; data['groupID'] = this.groupID;
data['userId'] = this.userId; data['userID'] = this.userID;
data['role'] = this.role; data['roleLevel'] = this.roleLevel;
data['joinTime'] = this.joinTime; data['joinTime'] = this.joinTime;
data['nickName'] = this.nickName; data['nickname'] = this.nickname;
data['faceUrl'] = this.faceUrl; data['faceURL'] = this.faceURL;
data['ext'] = this.ext; data['ext'] = this.ext;
return data; data['joinSource'] = this.joinSource;
} data['operatorUserID'] = this.operatorUserID;
}
class GroupInviteResult {
String? uid;
int? result;
GroupInviteResult({this.uid, this.result});
GroupInviteResult.fromJson(Map<String, dynamic> json) {
uid = json['uid'];
result = json['result'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['uid'] = this.uid;
data['result'] = this.result;
return data; return data;
} }
} }
class GroupMemberRole { class GroupMemberRole {
String? uid; String? userID;
int? setRole;
GroupMemberRole({this.uid, this.setRole}); /// 1 ordinary member, 2 group owners, 3 administrators
/// 1普通成员, 2群主3管理员
int? roleLevel;
GroupMemberRole({this.userID, this.roleLevel = 1});
GroupMemberRole.fromJson(Map<String, dynamic> json) { GroupMemberRole.fromJson(Map<String, dynamic> json) {
uid = json['uid']; userID = json['userID'];
setRole = json['setRole']; roleLevel = json['roleLevel'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['uid'] = this.uid; data['userID'] = this.userID;
data['setRole'] = this.setRole; data['roleLevel'] = this.roleLevel;
return data; return data;
} }
} }
class GroupApplicationInfo { class GroupApplicationInfo {
String? id;
String? groupID; String? groupID;
String? fromUserID; String? groupName;
String? toUserID; String? notification;
int? flag; //INIT = 0, REFUSE = -1, AGREE = 1 String? introduction;
String? groupFaceURL;
int? createTime;
int? status;
String? creatorUserID;
int? groupType;
String? ownerUserID;
int? memberCount;
String? userID;
String? nickname;
String? userFaceURL;
int? gender;
/// REFUSE = -1, AGREE = 1
/// -1拒绝1同意
int? handleResult;
String? reqMsg; String? reqMsg;
String? handledMsg; String? handledMsg;
int? createTime; int? reqTime;
String? fromUserNickName; String? handleUserID;
String? toUserNickName; int? handledTime;
String? fromUserFaceURL; String? ex;
String? toUserFaceURL;
String? handledUser;
int? type; //APPLICATION = 0, INVITE = 1
int? handleStatus; //UNHANDLED = 0, BY_OTHER = 1, BY_SELF = 2
int? handleResult; //REFUSE = 0, AGREE = 1
GroupApplicationInfo( GroupApplicationInfo({
{this.id,
this.groupID, this.groupID,
this.fromUserID, this.groupName,
this.toUserID, this.notification,
this.flag, this.introduction,
this.groupFaceURL,
this.createTime,
this.status,
this.creatorUserID,
this.groupType,
this.ownerUserID,
this.memberCount,
this.userID,
this.nickname,
this.userFaceURL,
this.gender,
this.handleResult,
this.reqMsg, this.reqMsg,
this.handledMsg, this.handledMsg,
this.createTime, this.reqTime,
this.fromUserNickName, this.handleUserID,
this.toUserNickName, this.handledTime,
this.fromUserFaceURL, this.ex,
this.toUserFaceURL, });
this.handledUser,
this.type,
this.handleStatus,
this.handleResult});
GroupApplicationInfo.fromJson(Map<String, dynamic> json) { GroupApplicationInfo.fromJson(Map<String, dynamic> json) {
id = json['id'];
groupID = json['groupID']; groupID = json['groupID'];
fromUserID = json['fromUserID']; groupName = json['groupName'];
toUserID = json['toUserID']; notification = json['notification'];
flag = json['flag']; introduction = json['introduction'];
groupFaceURL = json['groupFaceURL'];
createTime = json['createTime'];
status = json['status'];
creatorUserID = json['creatorUserID'];
groupType = json['groupType'];
ownerUserID = json['ownerUserID'];
memberCount = json['memberCount'];
userID = json['userID'];
nickname = json['nickname'];
userFaceURL = json['userFaceURL'];
gender = json['gender'];
handleResult = json['handleResult'];
reqMsg = json['reqMsg']; reqMsg = json['reqMsg'];
handledMsg = json['handledMsg']; handledMsg = json['handledMsg'];
createTime = json['createTime']; reqTime = json['reqTime'];
fromUserNickName = json['fromUserNickName']; handleUserID = json['handleUserID'];
toUserNickName = json['toUserNickName']; handledTime = json['handledTime'];
fromUserFaceURL = json['fromUserFaceURL']; ex = json['ex'];
toUserFaceURL = json['toUserFaceURL'];
handledUser = json['handledUser'];
type = json['type'];
handleStatus = json['handleStatus'];
handleResult = json['handleResult'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['id'] = this.id;
data['groupID'] = this.groupID; data['groupID'] = this.groupID;
data['fromUserID'] = this.fromUserID; data['groupName'] = this.groupName;
data['toUserID'] = this.toUserID; data['notification'] = this.notification;
data['flag'] = this.flag; data['introduction'] = this.introduction;
data['groupFaceURL'] = this.groupFaceURL;
data['createTime'] = this.createTime;
data['status'] = this.status;
data['creatorUserID'] = this.creatorUserID;
data['groupType'] = this.groupType;
data['ownerUserID'] = this.ownerUserID;
data['memberCount'] = this.memberCount;
data['userID'] = this.userID;
data['nickname'] = this.nickname;
data['userFaceURL'] = this.userFaceURL;
data['gender'] = this.gender;
data['handleResult'] = this.handleResult;
data['reqMsg'] = this.reqMsg; data['reqMsg'] = this.reqMsg;
data['handledMsg'] = this.handledMsg; data['handledMsg'] = this.handledMsg;
data['createTime'] = this.createTime; data['reqTime'] = this.reqTime;
data['fromUserNickName'] = this.fromUserNickName; data['handleUserID'] = this.handleUserID;
data['toUserNickName'] = this.toUserNickName; data['handledTime'] = this.handledTime;
data['fromUserFaceURL'] = this.fromUserFaceURL; data['ex'] = this.ex;
data['toUserFaceURL'] = this.toUserFaceURL;
data['handledUser'] = this.handledUser;
data['type'] = this.type;
data['handleStatus'] = this.handleStatus;
data['handleResult'] = this.handleResult;
return data; return data;
} }
} }
class GroupApplicationList { class GroupInviteResult {
int? count; String? userID;
List<GroupApplicationInfo>? user; int? result;
GroupApplicationList({this.count, this.user}); GroupInviteResult({this.userID, this.result});
GroupApplicationList.fromJson(Map<String, dynamic> json) { GroupInviteResult.fromJson(Map<String, dynamic> json) {
count = json['count']; userID = json['userID'];
if (json['user'] is List) { result = json['result'];
user = (json['user'] as List)
.map((e) => GroupApplicationInfo.fromJson(e))
.toList();
}
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['count'] = this.count; data['userID'] = this.userID;
if (this.user != null) { data['result'] = this.result;
data['user'] = this.user!.map((v) => v.toJson()).toList();
}
return data; return data;
} }
} }

View File

@@ -3,6 +3,9 @@ class Message {
String? serverMsgID; String? serverMsgID;
int? createTime; int? createTime;
int? sendTime; int? sendTime;
/// [ConversationType]
int? sessionType;
String? sendID; String? sendID;
String? recvID; String? recvID;
int? msgFrom; int? msgFrom;
@@ -10,8 +13,7 @@ class Message {
/// [MessageType] /// [MessageType]
int? contentType; int? contentType;
int? platformID; int? platformID;
List<String>? forceList; String? senderNickname;
String? senderNickName;
String? senderFaceUrl; String? senderFaceUrl;
String? groupID; String? groupID;
String? content; String? content;
@@ -20,11 +22,10 @@ class Message {
/// [MessageStatus] /// [MessageStatus]
int? status; int? status;
String? remark; OfflinePushInfo? offlinePush;
String? attachedInfo;
String? ex;
dynamic ext; dynamic ext;
/// [ConversationType]
int? sessionType;
PictureElem? pictureElem; PictureElem? pictureElem;
SoundElem? soundElem; SoundElem? soundElem;
VideoElem? videoElem; VideoElem? videoElem;
@@ -34,28 +35,30 @@ class Message {
CustomElem? customElem; CustomElem? customElem;
QuoteElem? quoteElem; QuoteElem? quoteElem;
MergeElem? mergeElem; MergeElem? mergeElem;
NotificationElem? notificationElem;
Message({ Message({
this.clientMsgID, this.clientMsgID,
this.serverMsgID, this.serverMsgID,
this.createTime, this.createTime,
this.sendTime, this.sendTime,
this.sessionType,
this.sendID, this.sendID,
this.recvID, this.recvID,
this.msgFrom, this.msgFrom,
this.contentType, this.contentType,
this.platformID, this.platformID,
this.forceList, this.senderNickname,
this.senderNickName,
this.senderFaceUrl, this.senderFaceUrl,
this.groupID, this.groupID,
this.content, this.content,
this.seq, this.seq,
this.isRead, this.isRead,
this.status, this.status,
this.remark, this.offlinePush,
this.attachedInfo,
this.ex,
this.ext, this.ext,
this.sessionType,
this.pictureElem, this.pictureElem,
this.soundElem, this.soundElem,
this.videoElem, this.videoElem,
@@ -65,30 +68,31 @@ class Message {
this.customElem, this.customElem,
this.quoteElem, this.quoteElem,
this.mergeElem, this.mergeElem,
this.notificationElem,
}); });
Message.fromJson( Message.fromJson(Map<String, dynamic> json) {
Map<String, dynamic> json) /* : clientMsgID = json['clientMsgID']*/ {
clientMsgID = json['clientMsgID']; clientMsgID = json['clientMsgID'];
serverMsgID = json['serverMsgID']; serverMsgID = json['serverMsgID'];
createTime = json['createTime']; createTime = json['createTime'];
sendTime = json['sendTime']; sendTime = json['sendTime'];
sendID = json['sendID']; sendID = json['sendID'];
recvID = json['RecvID']; recvID = json['recvID'];
msgFrom = json['msgFrom']; msgFrom = json['msgFrom'];
contentType = json['contentType']; contentType = json['contentType'];
platformID = json['platformID']; platformID = json['platformID'];
if (json['forceList'] is List) { senderNickname = json['senderNickname'];
forceList = (json['forceList'] as List).map((e) => '$e').toList();
}
senderNickName = json['senderNickName'];
senderFaceUrl = json['senderFaceUrl']; senderFaceUrl = json['senderFaceUrl'];
groupID = json['groupID']; groupID = json['groupID'];
content = json['content']; content = json['content'];
seq = json['seq']; seq = json['seq'];
isRead = json['isRead']; isRead = json['isRead'];
status = json['status']; status = json['status'];
remark = json['remark']; offlinePush = json['offlinePush'] != null
? OfflinePushInfo.fromJson(json['offlinePush'])
: null;
attachedInfo = json['attachedInfo'];
ex = json['ex'];
ext = json['ext']; ext = json['ext'];
sessionType = json['sessionType']; sessionType = json['sessionType'];
pictureElem = json['pictureElem'] != null pictureElem = json['pictureElem'] != null
@@ -116,28 +120,32 @@ class Message {
mergeElem = json['mergeElem'] != null mergeElem = json['mergeElem'] != null
? MergeElem.fromJson(json['mergeElem']) ? MergeElem.fromJson(json['mergeElem'])
: null; : null;
notificationElem = json['notificationElem'] != null
? NotificationElem.fromJson(json['notificationElem'])
: null;
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['clientMsgID'] = this.clientMsgID; data['clientMsgID'] = this.clientMsgID;
data['serverMsgID'] = this.serverMsgID; data['serverMsgID'] = this.serverMsgID;
data['createTime'] = this.createTime; data['createTime'] = this.createTime;
data['sendTime'] = this.sendTime; data['sendTime'] = this.sendTime;
data['sendID'] = this.sendID; data['sendID'] = this.sendID;
data['RecvID'] = this.recvID; data['recvID'] = this.recvID;
data['msgFrom'] = this.msgFrom; data['msgFrom'] = this.msgFrom;
data['contentType'] = this.contentType; data['contentType'] = this.contentType;
data['platformID'] = this.platformID; data['platformID'] = this.platformID;
data['forceList'] = this.forceList; data['senderNickname'] = this.senderNickname;
data['senderNickName'] = this.senderNickName;
data['senderFaceUrl'] = this.senderFaceUrl; data['senderFaceUrl'] = this.senderFaceUrl;
data['groupID'] = this.groupID; data['groupID'] = this.groupID;
data['content'] = this.content; data['content'] = this.content;
data['seq'] = this.seq; data['seq'] = this.seq;
data['isRead'] = this.isRead; data['isRead'] = this.isRead;
data['status'] = this.status; data['status'] = this.status;
data['remark'] = this.remark; data['offlinePush'] = this.offlinePush?.toJson();
data['attachedInfo'] = this.attachedInfo;
data['ex'] = this.ex;
data['ext'] = this.ext; data['ext'] = this.ext;
data['sessionType'] = this.sessionType; data['sessionType'] = this.sessionType;
data['pictureElem'] = this.pictureElem?.toJson(); data['pictureElem'] = this.pictureElem?.toJson();
@@ -149,21 +157,54 @@ class Message {
data['customElem'] = this.customElem?.toJson(); data['customElem'] = this.customElem?.toJson();
data['quoteElem'] = this.quoteElem?.toJson(); data['quoteElem'] = this.quoteElem?.toJson();
data['mergeElem'] = this.mergeElem?.toJson(); data['mergeElem'] = this.mergeElem?.toJson();
data['notificationElem'] = this.notificationElem?.toJson();
return data; return data;
} }
@override @override
bool operator ==(Object other) { bool operator ==(Object other) =>
if (other is Message) { identical(this, other) ||
return other._id == _id; other is Message &&
} runtimeType == other.runtimeType &&
return false; clientMsgID == other.clientMsgID;
}
@override @override
int get hashCode => super.hashCode; int get hashCode => clientMsgID.hashCode;
String? get _id => clientMsgID; void update(Message message) {
if (clientMsgID != message.clientMsgID) return;
// clientMsgID = message.clientMsgID;
serverMsgID = message.serverMsgID;
createTime = message.createTime;
sendTime = message.sendTime;
sendID = message.sendID;
recvID = message.recvID;
msgFrom = message.msgFrom;
contentType = message.contentType;
platformID = message.platformID;
senderNickname = message.senderNickname;
senderFaceUrl = message.senderFaceUrl;
groupID = message.groupID;
content = message.content;
seq = message.seq;
isRead = message.isRead;
status = message.status;
offlinePush = message.offlinePush;
attachedInfo = message.attachedInfo;
ex = message.ex;
ext = message.ext;
sessionType = message.sessionType;
pictureElem = message.pictureElem;
soundElem = message.soundElem;
videoElem = message.videoElem;
fileElem = message.fileElem;
atElem = message.atElem;
locationElem = message.locationElem;
customElem = message.customElem;
quoteElem = message.quoteElem;
mergeElem = message.mergeElem;
notificationElem = message.notificationElem;
}
} }
class PictureElem { class PictureElem {
@@ -192,7 +233,7 @@ class PictureElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['sourcePath'] = this.sourcePath; data['sourcePath'] = this.sourcePath;
if (this.sourcePicture != null) { if (this.sourcePicture != null) {
data['sourcePicture'] = this.sourcePicture?.toJson(); data['sourcePicture'] = this.sourcePicture?.toJson();
@@ -208,7 +249,7 @@ class PictureElem {
} }
class PictureInfo { class PictureInfo {
String? uuID; String? uuid;
String? type; String? type;
int? size; int? size;
int? width; int? width;
@@ -216,10 +257,10 @@ class PictureInfo {
String? url; String? url;
PictureInfo( PictureInfo(
{this.uuID, this.type, this.size, this.width, this.height, this.url}); {this.uuid, this.type, this.size, this.width, this.height, this.url});
PictureInfo.fromJson(Map<String, dynamic> json) { PictureInfo.fromJson(Map<String, dynamic> json) {
uuID = json['uuID']; uuid = json['uuid'];
type = json['type']; type = json['type'];
size = json['size']; size = json['size'];
width = json['width']; width = json['width'];
@@ -228,8 +269,8 @@ class PictureInfo {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['uuID'] = this.uuID; data['uuid'] = this.uuid;
data['type'] = this.type; data['type'] = this.type;
data['size'] = this.size; data['size'] = this.size;
data['width'] = this.width; data['width'] = this.width;
@@ -240,21 +281,21 @@ class PictureInfo {
} }
class SoundElem { class SoundElem {
String? uuID; String? uuid;
String? soundPath; String? soundPath;
String? sourceUrl; String? sourceUrl;
int? dataSize; int? dataSize;
int? duration; int? duration;
SoundElem( SoundElem(
{this.uuID, {this.uuid,
this.soundPath, this.soundPath,
this.sourceUrl, this.sourceUrl,
this.dataSize, this.dataSize,
this.duration}); this.duration});
SoundElem.fromJson(Map<String, dynamic> json) { SoundElem.fromJson(Map<String, dynamic> json) {
uuID = json['uuID']; uuid = json['uuid'];
soundPath = json['soundPath']; soundPath = json['soundPath'];
sourceUrl = json['sourceUrl']; sourceUrl = json['sourceUrl'];
dataSize = json['dataSize']; dataSize = json['dataSize'];
@@ -262,8 +303,8 @@ class SoundElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['uuID'] = this.uuID; data['uuid'] = this.uuid;
data['soundPath'] = this.soundPath; data['soundPath'] = this.soundPath;
data['sourceUrl'] = this.sourceUrl; data['sourceUrl'] = this.sourceUrl;
data['dataSize'] = this.dataSize; data['dataSize'] = this.dataSize;
@@ -316,7 +357,7 @@ class VideoElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['videoPath'] = this.videoPath; data['videoPath'] = this.videoPath;
data['videoUUID'] = this.videoUUID; data['videoUUID'] = this.videoUUID;
data['videoUrl'] = this.videoUrl; data['videoUrl'] = this.videoUrl;
@@ -335,26 +376,26 @@ class VideoElem {
class FileElem { class FileElem {
String? filePath; String? filePath;
String? uuID; String? uuid;
String? sourceUrl; String? sourceUrl;
String? fileName; String? fileName;
int? fileSize; int? fileSize;
FileElem( FileElem(
{this.filePath, this.uuID, this.sourceUrl, this.fileName, this.fileSize}); {this.filePath, this.uuid, this.sourceUrl, this.fileName, this.fileSize});
FileElem.fromJson(Map<String, dynamic> json) { FileElem.fromJson(Map<String, dynamic> json) {
filePath = json['filePath']; filePath = json['filePath'];
uuID = json['uuID']; uuid = json['uuid'];
sourceUrl = json['sourceUrl']; sourceUrl = json['sourceUrl'];
fileName = json['fileName']; fileName = json['fileName'];
fileSize = json['fileSize']; fileSize = json['fileSize'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['filePath'] = this.filePath; data['filePath'] = this.filePath;
data['uuID'] = this.uuID; data['uuid'] = this.uuid;
data['sourceUrl'] = this.sourceUrl; data['sourceUrl'] = this.sourceUrl;
data['fileName'] = this.fileName; data['fileName'] = this.fileName;
data['fileSize'] = this.fileSize; data['fileSize'] = this.fileSize;
@@ -378,7 +419,7 @@ class AtElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['text'] = this.text; data['text'] = this.text;
data['atUserList'] = this.atUserList; data['atUserList'] = this.atUserList;
data['isAtSelf'] = this.isAtSelf; data['isAtSelf'] = this.isAtSelf;
@@ -409,7 +450,7 @@ class LocationElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['description'] = this.description; data['description'] = this.description;
data['longitude'] = this.longitude; data['longitude'] = this.longitude;
data['latitude'] = this.latitude; data['latitude'] = this.latitude;
@@ -431,7 +472,7 @@ class CustomElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['data'] = this.data; data['data'] = this.data;
data['extension'] = this.extension; data['extension'] = this.extension;
data['description'] = this.description; data['description'] = this.description;
@@ -453,7 +494,7 @@ class QuoteElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['text'] = this.text; data['text'] = this.text;
data['quoteMessage'] = this.quoteMessage?.toJson(); data['quoteMessage'] = this.quoteMessage?.toJson();
return data; return data;
@@ -480,7 +521,7 @@ class MergeElem {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['title'] = this.title; data['title'] = this.title;
data['abstractList'] = this.abstractList; data['abstractList'] = this.abstractList;
data['multiMessage'] = this.multiMessage?.map((e) => e.toJson()).toList(); data['multiMessage'] = this.multiMessage?.map((e) => e.toJson()).toList();
@@ -488,7 +529,26 @@ class MergeElem {
} }
} }
class HaveReadInfo { class NotificationElem {
String? detail;
String? defaultTips;
NotificationElem({this.detail, this.defaultTips});
NotificationElem.fromJson(Map<String, dynamic> json) {
detail = json['detail'];
defaultTips = json['defaultTips'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['detail'] = this.detail;
data['defaultTips'] = this.defaultTips;
return data;
}
}
class ReadReceiptInfo {
String? uid; String? uid;
List<String>? msgIDList; List<String>? msgIDList;
int? readTime; int? readTime;
@@ -496,7 +556,7 @@ class HaveReadInfo {
int? contentType; int? contentType;
int? sessionType; int? sessionType;
HaveReadInfo( ReadReceiptInfo(
{this.uid, {this.uid,
this.msgIDList, this.msgIDList,
this.readTime, this.readTime,
@@ -504,7 +564,7 @@ class HaveReadInfo {
this.contentType, this.contentType,
this.sessionType}); this.sessionType});
HaveReadInfo.fromJson(Map<String, dynamic> json) { ReadReceiptInfo.fromJson(Map<String, dynamic> json) {
uid = json['uid']; uid = json['uid'];
if (json['msgIDList'] is List) { if (json['msgIDList'] is List) {
msgIDList = (json['msgIDList'] as List).map((e) => '$e').toList(); msgIDList = (json['msgIDList'] as List).map((e) => '$e').toList();
@@ -516,7 +576,7 @@ class HaveReadInfo {
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final data = Map<String, dynamic>();
data['uid'] = this.uid; data['uid'] = this.uid;
data['msgIDList'] = this.msgIDList; data['msgIDList'] = this.msgIDList;
data['readTime'] = this.readTime; data['readTime'] = this.readTime;
@@ -526,3 +586,32 @@ class HaveReadInfo {
return data; return data;
} }
} }
class OfflinePushInfo {
String? title;
String? desc;
String? ex;
String? iOSPushSound;
bool? iOSBadgeCount;
OfflinePushInfo(
{this.title, this.desc, this.ex, this.iOSPushSound, this.iOSBadgeCount});
OfflinePushInfo.fromJson(Map<String, dynamic> json) {
title = json['title'];
desc = json['desc'];
ex = json['ex'];
iOSPushSound = json['iOSPushSound'];
iOSBadgeCount = json['iOSBadgeCount'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['title'] = this.title;
data['desc'] = this.desc;
data['ex'] = this.ex;
data['iOSPushSound'] = this.iOSPushSound;
data['iOSBadgeCount'] = this.iOSBadgeCount;
return data;
}
}

View File

@@ -1,91 +1,388 @@
/// Is a friend not in the blacklist
/// 是好友不在黑名单
/// Not a friend on the blacklist
/// 不是好友在黑名单
/// Not a friend is not on the blacklist
/// 不是好友不在黑名单
class UserInfo { class UserInfo {
String uid; String? userID;
String? name; String? nickname;
String? icon; String? faceURL;
int? gender; int? gender;
String? mobile; String? phoneNumber;
String? birth; int? birth;
String? email; String? email;
String? ex; String? ex;
String? comment; int? createTime;
int? isInBlackList; String? remark;
String? reqMessage;
String? applyTime;
int? flag;
UserInfo( PublicUserInfo? publicInfo;
{required this.uid, FriendInfo? friendInfo;
this.name, BlacklistInfo? blackInfo;
this.icon,
this.gender, bool? isFriendship;
this.mobile, bool? isBlacklist;
UserInfo({
this.publicInfo,
this.friendInfo,
this.blackInfo,
this.isFriendship,
this.isBlacklist,
//
this.userID,
this.nickname,
this.faceURL,
this.phoneNumber,
this.birth, this.birth,
this.gender,
this.email, this.email,
this.ex, this.ex,
this.comment, this.createTime,
this.isInBlackList, this.remark,
this.reqMessage, });
this.applyTime,
this.flag});
UserInfo.fromJson(Map<String, dynamic> json) : uid = json['uid'] { // UserInfo.self(Map<String, dynamic> json) {
name = json['name']; // userID = json['userID'];
icon = json['icon']; // nickname = json['nickname'];
// faceURL = json['faceURL'];
// gender = json['gender'];
// phoneNumber = json['phoneNumber'];
// birth = json['birth'];
// email = json['email'];
// ex = json['ex'];
// createTime = json['createTime'];
// }
UserInfo.fromJson(Map<String, dynamic> json) {
publicInfo = json['publicInfo'] != null
? PublicUserInfo.fromJson(json['publicInfo'])
: null;
friendInfo = json['friendInfo'] != null
? FriendInfo.fromJson(json['friendInfo'])
: null;
blackInfo = json['blackInfo'] != null
? BlacklistInfo.fromJson(json['blackInfo'])
: null;
//
isFriendship = friendInfo != null;
isBlacklist = blackInfo != null;
userID = json['userID'] ?? _userID;
nickname = json['nickname'] ?? _nickname;
faceURL = json['faceURL'] ?? _faceUrl;
gender = json['gender'] ?? _gender;
phoneNumber = json['phoneNumber'] ?? _phoneNumber;
birth = json['birth'] ?? _birth;
email = json['email'] ?? _email;
remark = json['remark'] ?? _remark;
ex = json['ex'];
createTime = json['createTime'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['publicInfo'] = this.publicInfo?.toJson();
data['friendInfo'] = this.friendInfo?.toJson();
data['blackInfo'] = this.blackInfo?.toJson();
//
data['isFriendship'] = this.isFriendship;
data['isBlacklist'] = this.isBlacklist;
data['userID'] = this.userID;
data['nickname'] = this.nickname;
data['faceURL'] = this.faceURL;
data['gender'] = this.gender;
data['phoneNumber'] = this.phoneNumber;
data['birth'] = this.birth;
data['email'] = this.email;
data['ex'] = this.ex;
data['createTime'] = this.createTime;
data['remark'] = this.remark;
return data;
}
// bool get isFriendship => null != friendInfo;
//
// bool get isBlacklist => null != blackInfo;
bool get isMale => gender == 1;
String get _userID => isFriendship!
? friendInfo!.userID!
: (isBlacklist! ? blackInfo!.userID! : publicInfo!.userID!);
String? get _nickname => isFriendship!
? friendInfo?.nickname
: (isBlacklist! ? blackInfo?.nickname : publicInfo?.nickname);
String? get _faceUrl => isFriendship!
? friendInfo?.faceURL
: (isBlacklist! ? blackInfo?.faceURL : publicInfo?.faceURL);
int? get _gender => isFriendship!
? friendInfo?.gender
: (isBlacklist! ? blackInfo?.gender : publicInfo?.gender);
String? get _phoneNumber => friendInfo?.phoneNumber;
int? get _birth => friendInfo?.birth;
String? get _email => friendInfo?.email;
String? get _remark => friendInfo?.remark;
String getShowName() => _trimBlank(remark) ?? _trimBlank(nickname) ?? userID!;
static String? _trimBlank(String? value) {
if (value == null || value.trim().isEmpty) return null;
return value;
}
}
class PublicUserInfo {
String? userID;
String? nickname;
String? faceURL;
int? gender;
int? appMangerLevel;
PublicUserInfo({
this.userID,
this.nickname,
this.faceURL,
this.gender,
this.appMangerLevel,
});
PublicUserInfo.fromJson(Map<String, dynamic> json) {
userID = json['userID'];
nickname = json['nickname'];
faceURL = json['faceURL'];
gender = json['gender']; gender = json['gender'];
mobile = json['mobile']; appMangerLevel = json['appMangerLevel'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['userID'] = this.userID;
data['nickname'] = this.nickname;
data['faceURL'] = this.faceURL;
data['gender'] = this.gender;
data['appMangerLevel'] = this.appMangerLevel;
return data;
}
}
class FriendInfo {
String? userID;
String? nickname;
String? faceURL;
int? gender;
String? phoneNumber;
int? birth;
String? email;
String? remark;
String? ex;
int? createTime;
int? addSource;
String? operatorUserID;
FriendInfo({
this.userID,
this.nickname,
this.faceURL,
this.gender,
this.phoneNumber,
this.birth,
this.email,
this.remark,
this.ex,
this.createTime,
this.addSource,
this.operatorUserID,
});
FriendInfo.fromJson(Map<String, dynamic> json) {
// ownerUserID = json['ownerUserID'];
userID = json['userID'];
remark = json['remark'];
createTime = json['createTime'];
addSource = json['addSource'];
operatorUserID = json['operatorUserID'];
nickname = json['nickname'];
faceURL = json['faceURL'];
gender = json['gender'];
phoneNumber = json['phoneNumber'];
birth = json['birth']; birth = json['birth'];
email = json['email']; email = json['email'];
ex = json['ex']; ex = json['ex'];
comment = json['comment']; }
isInBlackList = json['isInBlackList'];
reqMessage = json['reqMessage']; Map<String, dynamic> toJson() {
applyTime = json['applyTime']; final data = Map<String, dynamic>();
flag = json['flag']; // data['ownerUserID'] = this.ownerUserID;
data['userID'] = this.userID;
data['remark'] = this.remark;
data['createTime'] = this.createTime;
data['addSource'] = this.addSource;
data['operatorUserID'] = this.operatorUserID;
data['nickname'] = this.nickname;
data['faceURL'] = this.faceURL;
data['gender'] = this.gender;
data['phoneNumber'] = this.phoneNumber;
data['birth'] = this.birth;
data['email'] = this.email;
data['ex'] = this.ex;
return data;
}
}
class BlacklistInfo {
String? userID;
String? nickname;
String? faceURL;
int? gender;
int? createTime;
int? addSource;
String? operatorUserID;
String? ex;
BlacklistInfo({
this.userID,
this.nickname,
this.faceURL,
this.gender,
this.createTime,
this.addSource,
this.operatorUserID,
this.ex,
});
BlacklistInfo.fromJson(Map<String, dynamic> json) {
userID = json['userID'];
nickname = json['nickname'];
faceURL = json['faceURL'];
gender = json['gender'];
createTime = json['createTime'];
addSource = json['addSource'];
operatorUserID = json['operatorUserID'];
ex = json['ex'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['userID'] = this.userID;
data['nickname'] = this.nickname;
data['faceURL'] = this.faceURL;
data['gender'] = this.gender;
data['createTime'] = this.createTime;
data['addSource'] = this.addSource;
data['operatorUserID'] = this.operatorUserID;
data['ex'] = this.ex;
return data;
}
}
class FriendshipInfo {
String? userID;
/// 1 means friend (and not blacklist)
/// 1表示好友并且不是黑名单
int? result;
FriendshipInfo({this.userID, this.result});
FriendshipInfo.fromJson(Map<String, dynamic> json) {
userID = json['userID'];
result = json['result'];
} }
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['uid'] = this.uid; data['userID'] = this.userID;
data['name'] = this.name; data['result'] = this.result;
data['icon'] = this.icon; return data;
data['gender'] = this.gender; }
data['mobile'] = this.mobile; }
data['birth'] = this.birth;
data['email'] = this.email; class FriendApplicationInfo {
String? fromUserID;
String? fromNickname;
String? fromFaceURL;
int? fromGender;
String? toUserID;
String? toNickname;
String? toFaceURL;
int? toGender;
int? handleResult;
String? reqMsg;
int? createTime;
String? handlerUserID;
String? handleMsg;
int? handleTime;
String? ex;
FriendApplicationInfo(
{this.fromUserID,
this.fromNickname,
this.fromFaceURL,
this.fromGender,
this.toUserID,
this.toNickname,
this.toFaceURL,
this.toGender,
this.handleResult,
this.reqMsg,
this.createTime,
this.handlerUserID,
this.handleMsg,
this.handleTime,
this.ex});
FriendApplicationInfo.fromJson(Map<String, dynamic> json) {
fromUserID = json['fromUserID'];
fromNickname = json['fromNickname'];
fromFaceURL = json['fromFaceURL'];
fromGender = json['fromGender'];
toUserID = json['toUserID'];
toNickname = json['toNickname'];
toFaceURL = json['toFaceURL'];
toGender = json['toGender'];
handleResult = json['handleResult'];
reqMsg = json['reqMsg'];
createTime = json['createTime'];
handlerUserID = json['handlerUserID'];
handleMsg = json['handleMsg'];
handleTime = json['handleTime'];
ex = json['ex'];
}
Map<String, dynamic> toJson() {
final data = Map<String, dynamic>();
data['fromUserID'] = this.fromUserID;
data['fromNickname'] = this.fromNickname;
data['fromFaceURL'] = this.fromFaceURL;
data['fromGender'] = this.fromGender;
data['toUserID'] = this.toUserID;
data['toNickname'] = this.toNickname;
data['toFaceURL'] = this.toFaceURL;
data['toGender'] = this.toGender;
data['handleResult'] = this.handleResult;
data['reqMsg'] = this.reqMsg;
data['createTime'] = this.createTime;
data['handlerUserID'] = this.handlerUserID;
data['handleMsg'] = this.handleMsg;
data['handleTime'] = this.handleTime;
data['ex'] = this.ex; data['ex'] = this.ex;
data['comment'] = this.comment;
data['isInBlackList'] = this.isInBlackList;
data['reqMessage'] = this.reqMessage;
data['applyTime'] = this.applyTime;
data['flag'] = this.flag;
return data; return data;
} }
String getShowName() {
if (null != comment && comment!.trim().isNotEmpty) {
return comment!;
} else if (null != name && name!.trim().isNotEmpty) {
return name!;
}
return uid;
}
bool get isMan => gender == 1;
bool get isWoman => gender == 2;
/// blacklist
bool get isBlocked => isInBlackList == 1;
/// friend application waiting handle /// friend application waiting handle
bool get isWaitingHandle => flag == 0; bool get isWaitingHandle => handleResult == 0;
/// friend application agreed /// friend application agreed
bool get isAgreed => flag == 1; bool get isAgreed => handleResult == 1;
/// friend application rejected /// friend application rejected
bool get isRejected => flag == -1; bool get isRejected => handleResult == -1;
/// exist friendship
bool get isFriendship => isAgreed;
} }

16
lib/src/utils.dart Normal file
View File

@@ -0,0 +1,16 @@
import 'dart:convert';
class Utils {
static List<T> toList<T>(String value, T f(Map<String, dynamic> map)) =>
(_formatJson(value) as List).map((e) => f(e)).toList();
static T toObj<T>(String value, T f(Map<String, dynamic> map)) =>
f(_formatJson(value));
static List<dynamic> toListMap(String value) => _formatJson(value);
static dynamic _formatJson(String value) => jsonDecode(value);
static String checkOperationID(String? obj) =>
obj ?? DateTime.now().millisecondsSinceEpoch.toString();
}

View File

@@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.8.1" version: "2.8.2"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@@ -21,7 +21,7 @@ packages:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.2.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
@@ -66,7 +66,14 @@ packages:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10" version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@@ -127,7 +134,7 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.4.2" version: "0.4.8"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
@@ -141,7 +148,7 @@ packages:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.1"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.14.0 <3.0.0"
flutter: ">=1.20.0" flutter: ">=1.20.0"

View File

@@ -1,6 +1,6 @@
name: flutter_openim_sdk name: flutter_openim_sdk
description: An instant messaging plug-in that supports Android and IOS. And the server is also all open source. description: An instant messaging plug-in that supports Android and IOS. And the server is also all open source.
version: 1.0.4 version: 2.0.0+1
homepage: https://www.rentsoft.cn homepage: https://www.rentsoft.cn
repository: https://github.com/OpenIMSDK/Open-IM-SDK-Flutter repository: https://github.com/OpenIMSDK/Open-IM-SDK-Flutter

View File

@@ -1,41 +1,5 @@
import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
/* const MethodChannel channel = MethodChannel('flutter_openim_sdk');
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
setUp(() {
channel.setMockMethodCallHandler((MethodCall methodCall) async {
return '42';
});
});
tearDown(() {
channel.setMockMethodCallHandler(null);
});
test('getPlatformVersion', () async {});*/
// Message m1 = new Message(clientMsgID: '1', content: 'c1');
// Message m2 = new Message(clientMsgID: '2', content: 'c2');
// Message m3 = new Message(clientMsgID: '3', content: 'c3');
// Message m4 = new Message(clientMsgID: '3', content: 'c4');
// List list = List.of([m1, m2, m3]);
//
// print(list.contains(m4));
// print(m1 == m4);
// print(m2 == m4);
// print(m3 == m4);
// var input = "1234 @abc @bbc @hha 开什么玩笑";
// RegExp exp = new RegExp(r"(@\w+) ");
// final ms = exp.allMatches(input);
// for (Match m in ms) {
// String match = m.group(0)??'';
// print('====$match ${m.start} ${m.end}');
// }
// DateTime now = DateTime.now();
// print('${now.millisecond}');
// print('${now.microsecondsSinceEpoch}');
// print('${now.millisecondsSinceEpoch}');
} }